Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATLAB Jirawat Kanjanapitak (Tae). What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D.

Similar presentations


Presentation on theme: "MATLAB Jirawat Kanjanapitak (Tae). What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D."— Presentation transcript:

1 MATLAB Jirawat Kanjanapitak (Tae)

2 What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D Plots, Matrices, Systems of Equations etc.

3 Getting Started

4 Open Program Click “MATLAB R2006a” on Desktop OR Go to “Start” All Program > MATLAB > MATLAB R2006a

5 MATLAB Desktop Default layout Arranging the Desktop including resizing, moving, and closing tools.

6 Taken from MATLAB Help

7 MATLAB for Problem Solving

8 Arithmetic Calculator >> 1+1 ans = 2 >> (7*5)+2 ans = 37 >> [(8+2^2)/(1*3)] ans = 4 Type in any basic arithmetic as shown  Click “Enter”

9 Basic Operations OperationMATLAB x + y x - y x yx*y x / y xyxy x^y exex exp(x) | x |abs(x) πpi sqrt(x)

10 Vectors To enter a vector >> v = [1 2 3] v = 1 2 3 To transpose a column vector to a row vector, use an apostrophe “‘“ >>v = [1 2 3] ’ v = 1 2 3 To increment using colon >> v = [1:5] v = 1 2 3 4 5 To increment other than1 >>v = [5:0.5:7] v = 5 5.5 6 6.5 7 To view individual entries in this vector v(2) Ans = 5.5

11 Vector Examples >> v = [1:5]; >> u = [0:-1:4]; u+v Ans: 1 1 1 1 1 v^2 Ans: 1 4 9 16 25 Note: Error message will appear from adding two vectors whose dimensions are different.

12 Matrices To enter a matrix 1 2 3 4 Use command >> a = [ 1 2; 3 4 ]

13 Matrix Examples >> a = [ 1 2; 3 4 ]; >> b = [ 0 1; 2 3 ]; >> a+b ans = 1 3 5 7 >>a*b ans = 4 7 8 15 T = a+b; >> inv(t) ans = -0.8750 0.3750 0.6250 -0.1250 >> inv(t)/t ans = 1.0000 -0.3750 -0.6250 0.2500

14 Plotting Use “plot” command Format: plot(x,y, ‘m’) The third input is a characteristic of the graph. yyellow mmagenta ccyan rred ggreen bblue kblack *star.dotted --dashed xx-mark

15 Plotting Examples x = 0:0.1:100; y = 2*x; plot (x,y,'--')

16 Plotting Examples 2 x = 0:0.1:5; y = sin (x); plot (x,y,'x')

17 Plotting Examples 3 x = linspace(0,2*pi,50); y = sin (x); z = cos (x); plot (x,y, x,z)

18 Sub-Plotting Use “subplot” command to put more than one plot in the same figure subplot (m,n,p) where; m = number of rows n = number of column p = plot number

19 Sub-Plotting Example x = linspace(0,2*pi,50); y = sin (x); z = cos (x); subplot (1,2,1) plot (x,y) subplot (1,2,2) plot (x,z)

20 Adding Text Below are the text adding related commands title (‘title name’) xlabel (‘label of the x-axis’) ylabel (‘label of the y-axis’) gtext (‘put text in the middle of plot’)

21 Adding Text Example x = 0:0.1:100; y = 2*x; plot (x,y,'--') title ('title name') xlabel ('label of the x-axis') ylabel ('label of the y-axis') gtext ('put text in the middle of plot')

22 Polynomials Vector is used to represented polynomial in MATLAB. For example; t 3 +4t 2 -3t+1 x = [1 4 -3 1] or x 5 +3x 2 -6 x = [1 0 0 3 0 -6]

23 Polynomial Examples To multiply two polynomial x = [1 2 3]; y = [2 4 6 8]; z = conv(x,y) z = 2 8 20 32 34 24 To devide two polynomial [xx, w] = deconv(z,y) xx = 1 2 3 w = 0 0 0

24 Getting HELP! Use “help” command help commandname

25


Download ppt "MATLAB Jirawat Kanjanapitak (Tae). What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D."

Similar presentations


Ads by Google