0% found this document useful (0 votes)
6 views14 pages

3D Curve and Surface Plots in MATLAB

The document contains MATLAB scripts for plotting various mathematical curves and surfaces using 3D plots, mesh grids, and contour plots. It includes multiple examples of parametric curves, surface plots with different color maps, and contour visualizations of functions. Each section is labeled with a specific task number, indicating different graphical representations of mathematical functions.

Uploaded by

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

3D Curve and Surface Plots in MATLAB

The document contains MATLAB scripts for plotting various mathematical curves and surfaces using 3D plots, mesh grids, and contour plots. It includes multiple examples of parametric curves, surface plots with different color maps, and contour visualizations of functions. Each section is labeled with a specific task number, indicating different graphical representations of mathematical functions.

Uploaded by

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

10_1

% Kurva r(t)=(t*cos(t),t*sin(t),t)
t=-10*pi:pi/100:10*pi;
x=t.*cos(t);
y=t.*sin(t);
h=plot3(x,y,t);
title('Kurva r(t)=(t*cos(t),t*sin(t),t)')
xlabel('x')
ylabel('y')
zlabel('z')
grid
% Akhir program

10_2
% Kurva r(t)=(1+cos(t),2+sin(t),z=1-cos(2t))
t=0*pi:pi/10:2*pi;
x=1+cos(t);
y=2+sin(t);
z=1-cos(2*t);
plot3(x,y,z);
title('Kurva r(t)=(1+cos(t),2+sin(t),z=1-cos(2t))')
xlabel('x')
ylabel('y')
zlabel('z')
grid
% Akhir program
10_3
x=-1:0.05:1; % Masukan nilai x
y=x; % Masukan nilai y
[X,Y]=meshgrid(x,y); % Membuat kemungkinan pasangan x dan y
Z=Y.^2-X.^2; % Masukan nilai z
mesh(X,Y,Z) % Membuat grafik
colormap(winter) % winter

x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
mesh(X,Y,Z)
colormap(hot)

10_4
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
mesh(X,Y,Z)
colormap(hot)
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
mesh(X,Y,Z)
colormap(cool)
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
mesh(X,Y,Z)
colormap(gray)

x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
mesh(X,Y,Z)
colormap(copper)
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
mesh(X,Y,Z)
colormap(summer)

x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
mesh(X,Y,Z)
colormap(bone)
10_5
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
surf(X,Y,Z)
colormap(winter)
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
surf(X,Y,Z)
colormap(hot)

x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
surf(X,Y,Z)
colormap(cool)
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
surf(X,Y,Z)
colormap(gray)

x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
surf(X,Y,Z)
colormap(copper)

x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
surf(X,Y,Z)
colormap(summer)
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
surf(X,Y,Z)
colormap(bone)

P10_6
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
meshc(X,Y,Z)
colormap(bone)
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
surfc(X,Y,Z)
colormap(bone)
P10_7
% Grafik R^2=x^2+y^2
x=[-10:0.5:10];
y=[-10:0.5:10];
[x,y]=meshgrid(-7:0.5:7);
R=sqrt(x.^2+y.^2);
z=sin(R)./R;
surfc(x,y,z)
% Akhir program
10_8
x=-1:0.05:1; % M
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
contour(Z)
colorbar

x=-1:0.05:1; % Masukan nilai x


y=x; % Masukan nilai y
[X,Y]=meshgrid(x,y); % Membuat semua kemungkinan pasangan x
dan y
Z=Y.^2-X.^2; % Masukan nilai Z
contour(Z) % Menggambar kontur dari nilai di Z
colorbar % Menambahkan bilah warna ke permukaan plot yang
menunjukkan skala warna
10_9
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2-X.^2;
contourf(Z)
colorbar

10_10
% Script file Tugas 10.10
% Surf dan Contour
x=-1:0.05:1;
y=x;
[X,Y]=meshgrid(x,y);
Z=Y.^2+X.^2;
surf(X,Y,Z)
hold on
contour(X,Y,Z)
title('Grafik Z=Y^2+X^2')
% Akhir program

You might also like