Download - MATLAB Introduction.pptx
-
7/27/2019 MATLAB Introduction.pptx
1/43
Sana Zahid
-
7/27/2019 MATLAB Introduction.pptx
2/43
Today's Topics
Books for MATLAB
Introduction to MATLAB
-
7/27/2019 MATLAB Introduction.pptx
3/43
MATLAB BOOKS
-
7/27/2019 MATLAB Introduction.pptx
4/43
-
7/27/2019 MATLAB Introduction.pptx
5/43
-
7/27/2019 MATLAB Introduction.pptx
6/43
-
7/27/2019 MATLAB Introduction.pptx
7/43
-
7/27/2019 MATLAB Introduction.pptx
8/43
-
7/27/2019 MATLAB Introduction.pptx
9/43
-
7/27/2019 MATLAB Introduction.pptx
10/43
Our main book
INTRODUCTION TO MATLAB 7
FOR ENGINEERS
byWILLIAM J. PALM III
-
7/27/2019 MATLAB Introduction.pptx
11/43
MATLAB - developed by Math Works Inc.
http://www.mathworks.com
MATLAB - acronym for MATrix LABoratory
Matrices and arrays - the heart ofMATLAB
Offers programming features - similar to other
languages
Offers GUI tools
Introduction to MATLAB
-
7/27/2019 MATLAB Introduction.pptx
12/43
Provides a variety of graphic output displays:
linear
log-log
semilog
polar
bar chart, and
contour plots
2-D and 3-D views
-
7/27/2019 MATLAB Introduction.pptx
13/43
Provides extensive numerical resources
Over 200 reliable, accurate mathematical
subprograms
The subprograms provide solutions to broad range of
mathematical problems including:
matrix algebra
complex arithmetic
differential equations nonlinear systems, and
many special functions
-
7/27/2019 MATLAB Introduction.pptx
14/43
many special functions available in all operating
systems: DOS
Windows9.x/NT
Unix
Macintosh
Same syntax for all platforms
Open system environment - access to source code
Allows - to mix MATLAB with FORTRAN or C
14
-
7/27/2019 MATLAB Introduction.pptx
15/43
-
7/27/2019 MATLAB Introduction.pptx
16/43
Default Appearance
-
7/27/2019 MATLAB Introduction.pptx
17/43
Simple MathScalar arithmetic operations
Exponentiation ^
Multiplication *
Right division /
Left division \
Addition +Subtraction -
-
7/27/2019 MATLAB Introduction.pptx
18/43
Simple Math 2+2.5+106
ans =
110.5000
4*25 + 2^3
ans =
108
-
7/27/2019 MATLAB Introduction.pptx
19/43
Order of Precedence
[{()}] from innermost
^ from left to right* & / from left to right
+ & - from left to right
-
7/27/2019 MATLAB Introduction.pptx
20/43
MATLAB Variables D = 2
D =
2
v = 3
v =
3
-
7/27/2019 MATLAB Introduction.pptx
21/43
MATLAB Variables rho = 1000; mu = 0.001;
NRe = D*v*rho/mu
NRe =
6000000
-
7/27/2019 MATLAB Introduction.pptx
22/43
MATLAB Workspace
To recall the variable
D
D =
2
Use arrow keys for scrolling
through previous commands
-
7/27/2019 MATLAB Introduction.pptx
23/43
MATLAB Workspace
List of variables in the workspace
who
Your variables are:
D NRe mu rho v
-
7/27/2019 MATLAB Introduction.pptx
24/43
Variable Naming RulesVariable names are case sensitive. For exampleNRe
and nRe are different MATLAB variables
Variable name can contain upto 31 characters.
Start with a letter, followed by letters, numbers or
underscores.
For example:NRe_2_the_power2by3
-
7/27/2019 MATLAB Introduction.pptx
25/43
Special variables
ans Default variable name used for resuts
pi Value of p
inf Stands for infinity (e.g., 1/0)
NaN Stands for Not-a-Number (e.g., 0/0)
i, j i = j =-1
-
7/27/2019 MATLAB Introduction.pptx
26/43
To clear a variable who
Your variables are:
D ans rho
NRe mu v
clear D
who
Your variables are:
NRe ans mu rho v
-
7/27/2019 MATLAB Introduction.pptx
27/43
To clear variables who
Your variables are:
NRe ans mu rho v
clear
who
-
7/27/2019 MATLAB Introduction.pptx
28/43
Complex Numbers
i
ans =
0 + 1.0000i
c1 = 2+3i
c1 =
2.0000 + 3.0000i
-
7/27/2019 MATLAB Introduction.pptx
29/43
Mathematical Functions
x=sqrt(2)/2
x =
0.7071
y=sin(x)
y =
0.6496
-
7/27/2019 MATLAB Introduction.pptx
30/43
Built-in Functions
Trigonometric
functionssin, cos, tan, sin, acos, atan,
sinh, cosh, tanh, asinh,
acosh, atanh, csc, sec, cot,
acsc, Exponential
functions
exp, log, log10, sqrt
Complex
functionsabs, angle, imag, real, conj
Rounding and
Remainder
functions
floor, ceil, round, sign
-
7/27/2019 MATLAB Introduction.pptx
31/43
Array Operations
x = [1 2 3 4 5 6 7 8 9 10]
x =
1 2 3 4 5 6 7 8 9 10
a = 1:2:10
a =
1 3 5 7 9
-
7/27/2019 MATLAB Introduction.pptx
32/43
Array Operations
y = sin(x)
y =
Columns 1 through 7
0.8415 0.9093 0.1411 -0.7568 -0.9589 -0.2794
0.6570
Columns 8 through 10
0.9894 0.4121 -0.5440
-
7/27/2019 MATLAB Introduction.pptx
33/43
Array Addressing
y(3)
ans =
0.1411
y(1:5)
ans =
0.8415 0.9093 0.1411 -0.7568 -0.9589
-
7/27/2019 MATLAB Introduction.pptx
34/43
Array Orientation
z = [1; 2; 3; 4]
z =
1
23
4
z'
ans =
1 2 3 4
-
7/27/2019 MATLAB Introduction.pptx
35/43
Array Manipulation
A = [1 2; 3 4; 5 6]
A =
1 2
3 45 6
B = [1 2 3; 4 5 6];
A+B??? Error using ==> +
Matrix dimensions must agree.
-
7/27/2019 MATLAB Introduction.pptx
36/43
Array Manipulation
A*B
ans =
9 12 15
19 26 3329 40 51
-
7/27/2019 MATLAB Introduction.pptx
37/43
Significance of. clear A = [1 2; 3 4];
B = [1 1; 2 2];
A.*B
ans =
1 2
6 8
-
7/27/2019 MATLAB Introduction.pptx
38/43
Significance of. A./B
ans =
1.0000 2.0000
1.5000 2.0000
A/B
Warning: Matrix is singular to working precision.
ans =
Inf Inf
Inf Inf
-
7/27/2019 MATLAB Introduction.pptx
39/43
Matrix Operations [A B]
ans =
1 2 1 1
3 4 2 2
ans-1
ans =
0 1 0 0
2 3 1 1
-
7/27/2019 MATLAB Introduction.pptx
40/43
Matrix Operations C = [A B]
C =
1 2 1 1
3 4 2 2
C(1,:)
ans =
1 2 1 1
C(:,2)
ans =
2
4
C(:,2:end)
ans =
2 1 1
4 2 2
-
7/27/2019 MATLAB Introduction.pptx
41/43
Matrix Functions size(C)
ans =
2 4
det(A)
ans =
-2
A
A =
1 2
3 4
inv(A)
ans =
-2.0000 1.0000
1.5000 -0.5000
-
7/27/2019 MATLAB Introduction.pptx
42/43
Matrix Functions & Arrays
Some functions: det, inv, diag, triu, tril,rank, eig, size,
Other such arrays:ones(n), ones(r, c)
zeros(n), zeros(r, c)
rand(n), rand(r,c)eye(n), eye(r,c)
-
7/27/2019 MATLAB Introduction.pptx
43/43
29. Oktober 2013 /