Matlab 三维绘图

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];

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值