1 / 20

Lecture 1: Matlab Universe

Lecture 1: Matlab Universe. Tom Rebold ENGR 52. Course Overview. To Buy Matlab. Student Version, $100 Can purchase, download online Link from ENGR196.3 class webpage Bookstore does not stock MATLAB retails for $1600, so it’s a pretty good deal BETTER DEAL: FreeMAT !!

karik
Download Presentation

Lecture 1: Matlab Universe

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 1: Matlab Universe Tom Rebold ENGR 52

  2. Course Overview

  3. To Buy Matlab • Student Version, $100 • Can purchase, download online • Link from ENGR196.3 class webpage • Bookstore does not stock • MATLAB retails for $1600, so it’s a pretty good deal • BETTER DEAL: FreeMAT !! • Open source version, powerful, free, legal

  4. Why MATLAB • 10x faster compared to other choices: • C++, Fortran, Java • Excel, MathCad, Mathematica, Labview • Matlab is a Very High Level Language • Designed for complex numerical calculations • Vast array of Toolboxes for different specialties • Excellent visualization tools • Symbolic math somewhat awkward • Simulink for modelling dynamic systems, 10x faster still

  5. This Morning's Agenda • MATLAB Overview • Working in MATLAB’s Environment • Simple calculations, variables • Finding the optimum size of a fuel tank • Vectors and plotting data • Plotting Marina weather data • Computing hypothetical wind power • 3D plotting

  6. MATLAB’s ENVIRONMENT

  7. Download week1.zip • Follow instructions in Lab1 • View toolbox demos • Experiment with workspace configuration

  8. Numeric Data • At it’s most basic level, Matlab can be used as a simple calculator, by typing in an arithmetic expression and hitting enter. For example, at the command prompt, type: >> 8/10 >>4 * 3 >>8/10 + 4*3 >>9^2 (what does the ^ operator do? )

  9. Arithmetic rules of precedence >> 8 + 3*5 >> 8 + (3*5) >> (8 + 3) * 5 >> 4^2 – 12 >> 8/4*2 >> 8/(4*2) >> 3*4^2 >> (3*4)^2 >> 27^(1/3) >> 27^1/3

  10. built in functions • Matlab has hundreds of built in functions to do more complicated math • sqrt(9) • log10(1000) • log(10) • pi • cos(pi) • i • exp(i*pi)

  11. Variables • Usually we need to hang on to the result of a calculation • We need a way to name memory for storage • Variable--name of a place in memory where information is stored • r = 8/10 • r • s=20*r • score = 4 * r + s • z = sqrt(1000) • z = sqrt(s)

  12. Assignment Operator • = means “gets” • Translation: MATLAB: r = 8/10 ENGLISH: r “gets” the value 8/10 • OK in Math x + 2 = 20 NOT OK IN MATLAB !! (only variable on Left Side)

  13. Expressing Math in MATLAB 2 • yx _______________x-y • 3x _______________2y

  14. Saving Work in Matlab Script (.m) files • You’ll want to build up complex calculations slowly • Try, correct, try again, improve, etc • .m Files store your calculations • Can be edited in Matlab • Can be re-executed by typing the file name

  15. Example .m file • Volume of a Cylinder. The volume of a cylinder is V= pr2h. A particular cylinder is 15 meters high with a radius of 8 meters. We want to construct another cylinder tank with a volume 20% greater, but with the same height. How large must its radius be? The session follows: • r = 8; • h = 15; • V = pi*r^2*h • V = V + 0.2*V  adds 20% to V • r = sqrt(V/ (pi * h)) Put this in a file calledcyl_volume.m to save retyping

  16. Solve some problems! • Pick any problem, solve it and print your solution .m file • Write name, turn in • You may wish to save your class .m files on a USB drive

  17. Marina weather data date/time (7 columns) condition temp, F humidity, % pressure, in wind direction wind speed, mph ##

  18. Sat, 21 Aug 2010 9:06 am PDT Cloudy 55 82 29.93 0 0 Sat, 21 Aug 2010 9:54 am PDT Cloudy 57 77 29.95 250 5 Sat, 21 Aug 2010 10:54 am PDT Cloudy 58 75 29.96 320 5 Sat, 21 Aug 2010 11:54 am PDT Cloudy 59 72 29.96 330 6 Sat, 21 Aug 2010 12:54 pm PDT MostlyCloudy 60 72 29.96 280 10

  19. http://wind-works.org/articles/PowerCurves.html

  20. http://k0lee.com/turbineeff.htm

More Related