0% found this document useful (0 votes)
3 views3 pages

MATLAB Graphing Techniques and Examples

Uploaded by

safa30632
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

MATLAB Graphing Techniques and Examples

Uploaded by

safa30632
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

clc;
clear all;
close all;
x=linspace(-3,3,30);
y=x.^2-10.*x+15;
plot(x,y,'m-.x','markeredgecolor','b','markerfacecolor','g','linewidth',1.5)
xlabel('X-Axis')
ylabel('Y-axis')
title('Graph of y=x^2-10x+15')
grid on

[Link];

clear all;
close all;
x=linspace(0,pi,30);
y1=sin(2*x)
y2=2*cos(2*x)
plot(x,y1,'b--o',x,y2,'r-.d')
xlabel('X-Axis')
ylabel('Y-axis')
title('multiple plots')
grid on

[Link];

clear all;

close all;
x=linspace(0,10);
subplot(2,2,1)
y1=x.^2;
plot(x,y1);
title('subplot 1: x^2')
subplot(2,2,2)
y2=x+2;
plot(x,y2);
title('subplot 2: x+2')
subplot(2,2,3)
y3=exp(x);
plot(x,y3);
title('subplot 3: exp(x)')
subplot(2,2,4)
y4=sin(x);
plot(x,y4);
title('subplot 4: sin(x)')

1. clc;
clear all;
close all;
x=linspace(0,1,30);
y=linspace(-1,1,30);
[X,Y]=meshgrid(x,y);
f=X.^3+Y.^3;
surf(X,Y,f)
xlabel('X-axis')
ylabel('Y-axis')
zlabel('f(x,y)')
title('3D plot');
colorbar

2. clc;
clear all;
close all;
x=linspace(0,1,30);
y=linspace(0,2,30);
[X,Y]=meshgrid(x,y);
f=2.*X+3.*Y+6;
surf(X,Y,f)
xlabel('X-axis')
ylabel('Y-axis')
zlabel('f(x,y)')
title('3D plot');
colorbar

3. clc;
clear all;
close all;
x=linspace(0,1,30);
y=linspace(-1,1,30);
[X,Y]=meshgrid(x,y);
f=cos(2*X)+sin(3*X);
surf(X,Y,f)
xlabel('X-axis')
ylabel('Y-axis')
zlabel('f(x,y)')
title('3D plot');
colorbar

You might also like