2. x = 0:0.1:2*pi; % first value is 0, last is 2*pi &
incrementad by 0.1
y = sin(x); % for sin wave
plot(x,y)
OR
x= linspace(0,2*pi,1000)
% taking 1000 samples between 0 to 2pi
y = sin(x); % for sin wave
plot(y)
0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
2
4. title(.)
>>title(‘This is the sinus function’)
xlabel(.)
>>xlabel(‘time’)
ylabel(.)
>>ylabel(‘sin(x)’)
legend(.)
>>legend ('sin_x')
grid
>> grid on
>> grid off
axis([xmin xmax ymin ymax])
Sets the minimum and maximum limits of the x- and y-axes
0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time
sin(x)
This is the sinus function
sin(x)
4
5. 0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time
sin(x) This is the sinus function
sin(x)
Data
signal
X axis
label
grids
Tick
mark
legend
Graph
title
Y axis
label
5
8. Line Specifies Line Specifies Marker Specifies
Style Color Type
Solid - red r plus sign +
dotted : green g circle o
dashed -- blue b asterisk *
dash-dot -. Cyan c point .
magenta m square s
yellow y diamond d
black k
0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Example:
x=0:0.1:2*pi;
y=sin(x);
plot(x,y,'r-*')
8
9. fplot(‘function’,[limits])
E.g.
Plot the equation
x^3-2*cos(0.66*x)+4*sin(2*x)-1 in the limit
between -3 & 3
>>fplot('x^3-2*cos(0.66*x)+4*sin(2*x)-1', [-3 3])
-3 -2 -1 0 1 2 3
-30
-20
-10
0
10
20
30
9