x=1:5;
y=[0 -2 4 11 5];
z=2:2:10;
plot3(x,y,z,'k*');
grid on;
xlabel('x');
ylabel('y');
zlabel('z');
title('3D plot');
axis equal; % 将轴等比例
ex1:
x=1:5;
y=[0 -2 4 11 5];
z=2:2:10;
plot3(x,y,z,'k*');
grid on;
xlabel('x');
ylabel('y');
zlabel('z');
title('3D plot');
axis equal; % 将轴等比例
view(47,44)% 姿态函数
for i=0:1E10
view(i,20);
drawnow;
end
ex2:
t=0:pi/50:10*pi;
st=sin(t);
ct=cos(t);
plot3(st,ct,t);
grid on;
axis equal;
for i=0:1E10
view(i,20);
drawnow;
end
t=0:pi/500:69*pi;
xt=(3+cos(sqrt(32)*t)).*cos(t);
yt=sin(sqrt(32)*t);
zt=(3+cos(sqrt(32)*t)).*sin(t);
plot3(xt,yt,t);
axis equal;
grid on;
xlabel('x');
ylabel('y');
zlabel('z');
bar -3D
mat=spiral(5);
bar3(mat);
title('3D');
3d-pie
surface :
[x,y]=meshgrid(-2*pi:0.1:2*pi);
z=cos(x)+sin(y);
surf(x,y,z);
title('cos(x)+sin(y)');
xlabel('x');
ylabel('y');
zlabel('z');
meshgrid:
光滑处理
ex:
[x,y,z]=sphere(30);
size(x);
% mesh(x,y,z);
surf(x,y,z);
% title('mesh of sphere');
title('surf of sphere');
改进:
[x,y,z]=sphere(30);
size(x);
% mesh(x,y,z);
surf(x,y,z,'FaceAlpha','0,4'); % FaceAlpha 透明度
% title('mesh of sphere');
title('surf of sphere');
2D-line:
x=-4:0.2:4;
y=sin(x);
hp=line(x,y,'LineWidth',3);
thand=text(2,0,'Sin(\pi)\rightarrow');
thand.BackgroundColor=[0.8,0.8,0.8];
thand.EdgeColor=[1 0 0];