We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17
MATLAB
Introductio n 23MAT107
This Photo by Unknown Author is licensed under CC BY-SA
•The Command Window •The Workspace •The Current Directory •Script •Live script Using MATLAB as a calculator •format long •format short •clear •clc •ctrl+C •who oa=7; b=cos(a), c=cosh(a)(we can enter multiple statements per line) ohelp odoc Basic plotting x = [1 2 3 4 5 6]; >> y = [3 -1 2 4 5 1]; >> plot(x,y) > x = 0:pi/100:2*pi; >> y = sin(x); >> plot(x,y)
NOTE: If you omit the increment, MATLAB automatically increments by 1.
>> xlabel(‘x = 0:2\pi’) >> ylabel(‘Sine of x’) >> title(‘Plot of the Sine function’) The color of a single curve is, by default, blue, but other colors are possible. The desired color is indicated by a third argument. For example, red is selected by plot(x,y,’r’). Multiplot x = 0:pi/100:2*pi; y1 = 2*cos(x); y2 = cos(x); y3 = 0.5*cos(x); plot(x,y1,'--y',x,y2,'-m',x,y3,':r’) xlabel('0 \leq x \leq 2\pi') ylabel('Cosine functions') legend('2*cos(x)','cos(x)','0.5*cos(x)') Specifying line styles and colors Plot these functions as different figures. Choose your own domain and increments Plot these functions in same graph 1. . (Graph1) 2. (Graph 2) 3. . (Graph 3) If you are done with basics still want to learn more, go for next slides Try these keywords using doc or help syms fplot subplot simplify function_handle
This Photo by Unknown Author is licensed under CC BY-NC-ND
Explore matrices D O C “ M ATR I C ES A N D A R R AYS”