You are on page 1of 6

LAB-04

OBJECTIVE:
To generate the 3D plotting by Using MATLAB.

TASK 01:
Clc GRAPH:
x=0:0.1:100;
y=cos(x)
z=sin(x)
plot3(x,y,z,'r')
xlabel('x')
ylabel('y=cos(x)')
zlabel('z=sin(x)')
GRAPH:

TASK: 03
TASK02 Clc
clc x=1:5;
x=1:5; y=1:5;
y=1:5; [x,y]=meshgrid(x,y)
[x,y]=meshgrid(x,y) z=x+y
z=x+y subplot(313)
subplot(211) mesh(x,y,z)
mesh(x,y,z) xlabel('x')
xlabel('x') ylabel('y')
ylabel('y') zlabel('z')
zlabel('z') subplot(332)
subplot(212) surf(x,y,z)
surf(x,y,z) xlabel('x')
xlabel('x') ylabel('y')
ylabel('y') zlabel('z')
zlabel('z') subplot(313)
plot3(x,y,z) TASK: 05:
xlabel('x') Clc
ylabel('y') clear all
zlabel('z') t=linspace(0,5*pi,500);
grid y=cos(t)
z=sin(t);
GRAPH: plot3(y,z,t)
axis tight
grid on
xlabel('cos')
ylabel('sin')
zlabel('time')
GRAPH:

TASK: 04:
clc
TASK 06:
clear all
z=peaks(25)
X=1:0;
figure
Y=X;
mesh(z)
[x,y]=meshgrid(X,Y)
GRAPH:
z=zeros(size(x))
mesh(x,y,z)
axis square
figure
surf(x,y,z)
axis tight
Figure
GRAPH:
Task 8:
TASK 07 z=peaks(25)
z=peaks(25); figure
figure mesh(z)
mesh(z) surf(z) surf(z)
surfl(z) surfl(z)
color map(pink) colormap(pink)
shading interp shading interp
figure contour(z,16)
mesh(z) GRAPH:
surf(z)
surfl(z)
color map(default)
GRAPH:

TASK NO 9
x=-2:0.2:2;
y=-1:0.2:1;
[xx,yy]=meshgrid(x,y)
zz=xx.*exp(-xx.^2-yy.^2)
[px,py]=gradient(zz,0.2,0.2)
quiver(x,y,px,py)
xlim([-2.5,2.5])
GRAPH:
TASK NO 10
x=-2:0.2:2; TASK NO 12
y=-2:0.25:2; [x,y]=peaks(30)
z=-2:0.16:2, z=exp(-0.9*(x.^2+0.5*(x-y).^2))
[x,y,z]=meshgrid(x,y,z) -2 -1 0 1 2 -2 -1 0 1 2 -2 -1 0 1 2
v=x.*exp(-x.^2-y.^2-z.^2) x y z surf(x,y,z)
xslice=[-1.2,0.8,2] xlabel('\bf xaxis')
yslice=2 ylabel('\bf yaxis')
zslice=[-2,0] zlabel('\bf zaxis')
slice(x,y,z,v,xslice,yslice,zslice) title('\bf surface plot')
xlabel('x') color bar
ylabel('y') z=(10*sin(t))
zlabel('z') mesh(x,y,z)
GRAPH: GRAPH:

TASK NO 11
TASK NO 13
[x,y]=meshgrid(-10:0.1:10)
[x,y]=peaks(30)
t=sqrt(x.^2+y.^2)
z=[(x.^2)-(y.^2)] ribbon(z)
z=(10*sin(t))
title('bf ribbon plot')
mesh(x,y,z)
GRAPH:
GRAPH:
TASK NO 14
[x,y]=peaks(30)
z=exp(-x.^2-y.^2)
contour3(x,y,z) title('\bf contour plot')
GRAPH:

TASK NO 15
[x,y,z]=meshgrid(-10:0.2:10)
v=[exp((x.^2)-(y.^3)-(z.^5))]
xslice=0.1
yslice=5
zslice=0
slice(x,y,z,v,xslice,yslice,zslice)
colorbar title('\bf slice plot')
GRAPH:

Conclusion
It is concluded that, MATLAB is great for making 3D
plots. It helps you display complex data in a clear and
visual way, making it handy for various applications.

You might also like