Matlab Doc
Matlab Doc
Input:-
%1.plot of a circle with centre (3,4) and radius 2
clc
clear all
t=linspace(0,2*pi,40);
x=3+2*cos(t);
y=4+2*sin(t);
plot(x,y,'b*:')
axis equal
xlabel('x(m)')
ylabel('y(m)')
title('graph of (x-1)^2+(y-3)^2=4')
legend('circle')
%%
% 2. multiple plots in a figure window (using command hold on)
clc
clear all
x=linspace(0,2*pi);
plot(x,sin(x),'r*')
hold on
plot(x,cos(x),'g.')
plot(x,cos(2*x),'b-+')
legend('sin(x)','cos(x)','cos(2*x)')
%%
%3. multiple plots in a figure window (without command plot)
clc
clear all
x=linspce(0,2*pi,101);
plot(x,sin(x),'r+',x,cos(x),'b-',x,cos(2*x),'g-')
legend('sin(x)','cos(x)','cos(2*x)')
%%
%4. mutiple graphs in a figure window using command subplot
clc
clear all
x=0:0.1:2*pi;
subplot(2,2,1)
plot(x,sin(x),'b-.');
subplot(2,2,2)
plot(x,cos(x),'r-*');
subplot(2,2,3)
plot(x,exp(-x),'go')
subplot(2,2,4);
plot(x,sin(3*x),'ms')
%%
%5. plot a curve in space
clc
clear all
t=linspace(0,2*pi);
x=cos(t);y=sin(t);z=sin(5*t);
plot3(x,y,z,'b.-','markersize',7)
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
title('curve in space')
OUTPUT FIGURES:-