matlab三维绘图注释,美赛matlab3D绘图必备.ppt

MatLab绘图 三维图形 clf;t=(pi*(0:1000)/1000)'; y1=sin(t);y2=sin(10*t);y12=sin(t).*sin(10*t); subplot(2,2,1),plot(t,y1);axis([0,pi,-1,1]) subplot(2,2,2),plot(t,y2);axis([0,pi,-1,1]) subplot('position',[0.2,0.05,0.6,0.45]) plot(t,y12,'b-',t,[y1,-y1],'r:');axis([0,pi,-1,1]) 三维图形 [x,y] = meshgrid(-3:0.3:3,-2:0.3:2); z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y); mesh(x,y,z) axis([-3,3,-2,2,-0.7,1.5]) colorbar figure,surf(x,y,z), axis([-3,3,-2,2,-0.7,1.5]),colorbar 三维图形 三维线的绘图函数—plot3 plot3(u1,v1,w1,u2,v2,w2…) 空间的直线 plot3([x1;x2],[y1;y2],[z1;z2]) ps.三维图形的注释中,除了用zlabel标注z轴外,其他二维图形中的函数都可使用。 三维图形 t=0:pi/50:10*pi; plot3(sin(t),cos(t),t) title('Helix'),xlabel('sin(t)'),ylabel('cos(t)'),zlabel('t'); text(0,0,0,'Origin') 三维图形 三维图形 例,作一线框盒 盒子尺寸为 Lx*Ly*Lz. 创建函数boxplot3,画出盒子六个面的四条边。盒子位置和方向由两个对角坐标P(x0,y0,z0)和P(x0+Lx,y0+Ly,z0+Lz)确定。 >> boxplot3(1,1,1,3,5,7) >> boxplot3(4,6,8,4,5,1) >> boxplot3(8,11,9,1,1,1) 三维图形 function boxplot3(x0,y0,z0,lx,ly,lz) %(0,0,0) ,(1,1,1) x=zeros(1,8);x(1:4)=x0;x(5:8)=x0+lx; % x=0 0 0 0 1 1 1 1 y=zeros(1,8);y(1:8)=y0;y(3:4)=y0+ly;y(7:8)=y0+ly; z=zeros(1,8);z(1:8)=z0;z(2:3)=z0+lz;z(6:7)=z0+lz; %y= 0 0 1 1 0 0 1 1 %z= 0 1 1 0 0 1 1 0 index=zeros(6,5); index(1,:)=[1:4 1]; index(2,:)=[5:8 5]; index(3,:)=[1 2 6 5 1]; index(4,:)=[4 3 7 8 4]; index(5,:)=[2 6 7 3 2]; index(6,:)=[1 5 8 4 1]; for k=1:6 plot3(x(index(k,:)),y(index(k,:)),z(index(k,:))) hold on end 三维图形 三维图形 柱形图—cylinder [x,y,z]=cylinder [x,y,z]=cylinder(r) [x,y,z]=cylinder(r,n) >>cylinder >>cylinder(100,100) 三维图形 三维图形 >>t=0:pi/10:2*pi; >>cylinder(2+cos(t)); 三维图形 X=0:.2:pi; R=exp(-X.^2/2).*sin(X); % plot(R,X) % axis('square') figure; [x,y,z]=cylinder(R,20); surf(x,y,z*pi) axis([-0.6,0.6,-0.6,0.6,0,pi]) 三维图形 三维图形 三维饼图—pie3 >> x=[1 3 5 7 4]; >> idex=[0 0 1 0 1]; >> pie3(x,idex) >> legend('x','y','z','m','n') 三维图形 曲面—mesh & surf 表达式 surf

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值