da48761cb069484e8e657e797f85073d.ppt
- Количество слайдов: 17
Lecture 1: Matlab Universe Tom Rebold ENGR 52
Course Overview
The Way the Class Works n n n I lecture for 15 – 20 minutes You do lab for 30 – 40 minutes Labs link to extra Problems online for fast students Everyone turn in a solution to the last problem they solve today HOMEWORK: Bring in 3 Math problems to solve…medium, hard, impossible q We’ll have independent study time
To Buy Matlab n n Student Version, $100 Can purchase, download online q n n n Link from ENGR 196. 3 class webpage Bookstore does not stock MATLAB retails for $1600, so it’s a pretty good deal BETTER DEAL: Free. MAT !! q Open source version, powerful, free, legal
Why MATLAB n 10 x faster compared to other choices: q q n C++, Fortran, Java Excel, Math. Cad, Mathematica, Labview Matlab is a Very High Level Language q q q Designed for complex numerical calculations Vast array of Toolboxes for different specialties Excellent visualization tools Symbolic math somewhat awkward Simulink for modelling dynamic systems, 10 x faster still
Today’s Agenda n n n MATLAB Overview Working in MATLAB’s Environment Simple calculations, variables
MATLAB’s ENVIRONMENT
Download week 1. zip n Follow instructions in Lab 1 q q View toolbox demos Experiment with workspace configuration
Numeric Data n 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? )
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
built in functions Matlab has hundreds of built in functions to do more complicated math n q q q q sqrt(9) log 10(1000) log(10) pi cos(pi) i exp(i*pi)
Variables Usually we need to hang on to the result of a calculation n We need a way to name memory for storage Variable--name of a place in memory where information is stored q q n n n r = 8/10 r s=20*r score = 4 * r + s z = sqrt(1000) z = sqrt(s)
Assignment Operator n n = means “gets” Translation: MATLAB: r = 8/10 ENGLISH: r “gets” the value 8/10 n OK in Math x + 2 = 20 NOT OK IN MATLAB !! (only variable on Left Side)
Expressing Math in MATLAB 2 n yx x-y n 3 x 2 y _______________
Saving Work in Matlab Script (. m) files n You’ll want to build up complex calculations slowly q q 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
Example. m file Volume of a Cylinder. The volume of a cylinder is V= pr 2 h. 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? n The session follows: q q q r = 8; h = 15; V = pi*r^2*h V = V + 0. 2*V r = sqrt(V/ (pi * h)) Put this in a file called cyl_volume. m to save retyping adds 20% to V
Solve some problems! n Pick any problem, solve it and print your solution. m file n Write name, turn in n You may wish to save your class. m files on a USB drive
da48761cb069484e8e657e797f85073d.ppt