0% found this document useful (0 votes)
5 views

Matlab Doc

The document provides MATLAB code examples for plotting various mathematical functions, including a circle, multiple plots, and 3D curves. It demonstrates the use of commands like 'hold on', 'subplot', and 'ezplot' to create different types of visualizations. Each section includes clear instructions and comments for generating specific plots.

Uploaded by

sbc24042006
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Matlab Doc

The document provides MATLAB code examples for plotting various mathematical functions, including a circle, multiple plots, and 3D curves. It demonstrates the use of commands like 'hold on', 'subplot', and 'ezplot' to create different types of visualizations. Each section includes clear instructions and comments for generating specific plots.

Uploaded by

sbc24042006
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

MATLAB DAY 2

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')

%% 6. graph of curve through ezplot command


clc
clear all
syms x
f=sin(2*x)+cos(3*x)
ezplot(f)
d=[0 3]
figure(2)
ezplot(f,d)

OUTPUT FIGURES:-

You might also like