ch 2 getting started with matlab
Post on 14-Apr-2018
260 views
TRANSCRIPT
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 1/18
Chapter 2:
Getting Started withMATLAB
MATLAB
for Scientist and Engineers
Using Symbolic Toolbox
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 2/18
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.
2
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 3/18
Starting MATLAB
Start – All Programs – MATLAB – R2009b … Create your own work space.
Customize the startup script.
3
Create a new folder under c:\c:\workM
edit 'startupsav.m' save as 'startup.m'
startup.m
cd c:\workM
disp(['MATLAB v' version]);
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 4/18
Overview of MATLAB Desktop
4
Command Window
Editor Workspace
Command History
Window
CurrentFolder
Content
Browser
Show how to use Desktop.
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 5/18
Test Ride of MATLAB: bench
Type bench in the command window.
5
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 6/18
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
6Show demo: getting_started_with_matlab.m
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 7/18
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
7Show demo: working_with_ide.m
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 8/18
Match the pairs.
Quiz: MATLAB Windows
8
Main window, enters variables,
runs programs.
Logs commands entered in the
Command window.
Shows the files in the current
directory.
Creates and debugs script and
function files.
Command Window
Editor Window
Command History
Window
Workspace Window
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 9/18
MATLAB is a Very Good Calculator!
Write down the answers.
9
-4 + 7 * ( 2 - 5 ) / 3.14 7 2 5
43.14
2^3 - sqrt(25) + exp(3) 3 32 25 e
2.51e3 + 2/3*pi 3 12.51 10 2
3
MathematicalExpressions
MATLABExpressions
YourAnswers
(2+3*i)*(1-2*i)^2 2
(2 3 ) 1 2i i
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 10/18
Basic Math Expressions
2.1+3 cos log round nchoosek min
98-3.2 acos log10 rem besselj max
-67*34 cosd sqrt mod beta size
81/8 acosd abs factor erf primes
7.1^4 cosh angle isprime erfc gcd
1.2e3 acosh conj primes gamma lcd
3+4*i tan imag gcd legendre mean
pi atan2 real lcm factorial roots
eps asin floor rat sum poly
exp asind ceil perms prod conv
10
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 11/18
Exercise: Math Expressions
Evaluate the following expressions when x = 1.25
11
2 3310log x x
34 tan ln6
x x x e
2
3
sin ( / 6)23 2010
9 652 x
>>
>>
>>
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 12/18
Exercise: Geometry
Find the volume of the oil tank below.
12
MATLAB Expression
20m
ANS
24m
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 13/18
Variables
Assign the results into variables.
13
x = 3^4 + 27^(1/3) 4 33 27 x
y = (2+3i)*(1-2i) (2 3 )(1 2 ) y i i
z = sqrt( x^2 + y^2 ) ; 2 2 z x y
Do not print the answer!
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 14/18
Workspace Variables
Variables live in the MATLAB workspace.
14
>> 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
who a*
whos
clc
List variable names.
List variable names
beginning with a.
List variable in long
format.
Clear command window.
clear Clear variables from
memory. help doc
what
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 15/18
Exercise: Geometry & Trigonometry
Find the distance between C2 and C4.
15
1C
2C
3C
4C
1
2
3
4
16
6.5
12
9.5
R mm
R mm
R mm
R mm
a
b
c
2 2 2 2 cosc a b ab
Hint: Use the following identity.
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 16/18
Exercise: Your Solution
Mathematical Expressions
MATLAB Expressions
Your Answer:
16
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 17/18
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.
17
7/29/2019 Ch 2 Getting Started With MATLAB
http://slidepdf.com/reader/full/ch-2-getting-started-with-matlab 18/18
Q & A
18