180 likes | 351 Views
Chapter 2: Getting Started with MATLAB. MATLAB for Scientist and Engineers Using Symbolic Toolbox. You are going to. Familiarize yourself with MATLAB desktop, See how simple it is to use MATLAB, yet powerful, Express simple math expressions in MATLAB tongue,
E N D
Chapter 2:Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox
You are going to • Familiarize yourself with MATLAB desktop, • See how simple it is to use MATLAB, yet powerful, • Express simple math expressions in MATLAB tongue, • Solve mathematical problems using MATLAB, • And finally, be glad to know MATLAB is with you.
Starting MATLAB • Start – All Programs – MATLAB – R2009b … • Create your own work space. • Customize the startup script. Create a new folder under c:\ c:\workM edit 'startupsav.m' save as 'startup.m' startup.m cd c:\workM disp(['MATLAB v' version]);
Overview of MATLAB Desktop Current Folder Editor Workspace Command History Window Content Browser Command Window Show how to use Desktop.
Test Ride of MATLAB: bench • Type bench in the command window.
Getting Started with MATLAB • Through the demonstration, you will be able to • do simple arithmetic operations • generating arrays using : operator • disable output using ; • entering matrices • use help systems • display the size of matrices • perform matrix operations • selecting part of matrices • plotting matrices Show demo: getting_started_with_matlab.m
Working in the Desktop • Through the demonstration, you will be able to • calculate values for a function • plot the results • edit the previous commands • display the variables using whos • modify variables directly using variable editor • plot data at workspace browser • save and load part / all of the variable • adjusting window layouts • docking/undocking Show demo: working_with_ide.m
Quiz: MATLAB Windows • Match the pairs. Logs commands entered in the Command window. Command Window Editor Window Main window, enters variables, runs programs. Command History Window Shows the files in the current directory. Workspace Window Creates and debugs script and function files.
MATLAB is a Very Good Calculator! • Write down the answers. Mathematical Expressions MATLAB Expressions Your Answers -4 + 7 * ( 2 - 5 ) / 3.14 2^3 - sqrt(25) + exp(3) 2.51e3 + 2/3*pi (2+3*i)*(1-2*i)^2
Exercise: Math Expressions • Evaluate the following expressions when x = 1.25 >> >> >>
Exercise: Geometry • Find the volume of the oil tank below. 24m 20m MATLAB Expression ANS
Variables • Assign the results into variables. x = 3^4 + 27^(1/3) y = (2+3i)*(1-2i) z = sqrt( x^2 + y^2 ) ; Do not print the answer!
Workspace Variables • Variables live in the MATLAB workspace. >> x = 3^4 + 27^(1/3) x = 84 >> y = (2+3i)*(1-2i); >> z = sqrt( x^2 + y^2 ); >> who Your variables are: ans x y z >> clear >> who >> who List variable names. who a* List variable names beginning with a. whos List variable in long format. clc Clear command window. clear Clear variables from memory. help doc what
Exercise: Geometry & Trigonometry • Find the distance between C2 and C4. Hint: Use the following identity.
Exercise: Your Solution • Mathematical Expressions • MATLAB Expressions • Your Answer:
Key Takeaways • Now, you know how to • customize the MATLAB startup script. • use the MATLAB desktop windows. • change the layout of the desktop windows. • evaluate mathematical expressions.