资源描述:
《Matlab画三维图像》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Matlab画函数图一、螺旋线1.静态螺旋线a=0:0.1:20*pi;h=plot3(a.*cos(a),a.*sin(a),2.*a,'b','linewidth',2);axis([-50,50,-50,50,0,150]);gridonset(h,'erasemode','none','markersize',22);xlabel('x轴');ylabel('y轴');zlabel('z轴');title('静态螺旋线'); 2.动态螺旋线t=0:0.1:10*pi;i=1;h=plot3(sin(t(i)),cos(t(i))
2、,t(i),'*','erasemode','none');gridonaxis([-22-22035])fori=2:length(t) set(h,'xdata',sin(t(i)),'ydata',cos(t(i)),'zdata',t(i)); drawnow pause(0.01)endtitle('动态螺旋线');(图略) 3.圆柱螺旋线t=0:0.1:10*pi;x=r.*cos(t);y=r.*sin(t);z=t;plot3(x,y,z,'h','linewidth',2);gridonaxis('squa
3、re')xlabel('x轴');ylabel('y轴');zlabel('z轴');title('圆柱螺旋线') 二、旋转抛物面b=0:0.2:2*pi;[X,Y]=meshgrid(-6:0.1:6);Z=(X.^2+Y.^2)./4;meshc(X,Y,Z);axis('square')xlabel('x轴');ylabel('y轴');zlabel('z轴');title('旋转抛物面')或直接用:ezsurfc('(X.^2+Y.^2)./4') 三、椭圆柱面loadclownezsurf('(2*cos(u))','4*
4、sin(u)','v',[0,2*pi,0,2*pi])view(-105,40) %视角处理shadinginterp %灯光处理colormap(map) %颜色处理gridon %添加网格线axisequal %使x,y轴比例一致xlabel('x轴');ylabel('y轴');zlabel('z轴'); %添加坐标轴说明title('椭圆柱面')
5、 %添加标题四、椭圆抛物面b=0:0.2:2*pi;[X,Y]=meshgrid(-6:0.1:6);Z=X.^2./9+Y.^2./4;meshc(X,Y,Z);axis('square')xlabel('x轴');ylabel('y轴');zlabel('z轴');title('椭圆抛物面')或直接用:ezsurfc('X.^2./9+Y.^2./4')五、'双叶双曲面ezsurf('8*tan(u)*cos(v)','8.*tan(u)*sin(v)','2.*sec(u)',[-pi./2,3*pi./2,0,2*pi])a
6、xisequalgridonaxissquarexlabel('x轴');ylabel('y轴');zlabel('z轴');title('双叶双曲面')六、双曲柱面loadclownezsurf('2*sec(u)','2*tan(u)','v',[-pi/2,pi/2,-3*pi,3*pi])holdon %在原来的图上继续作图ezsurf('2*sec(u)','2*tan(u)','v',[pi/2,3*pi/2,-3*pi,3*pi])colormap(map)shadinginterpview(-15
7、,30)axisequalgridonaxisequalxlabel('x轴');ylabel('y轴');zlabel('z轴');title('双曲柱面')七、双曲抛物面(马鞍面)[X,Y]=meshgrid(-7:0.1:7);Z=X.^2./8-Y.^2./6;meshc(X,Y,Z);view(85,20)axis('square')xlabel('x轴');ylabel('y轴');zlabel('z轴');title('双曲抛物面')或直接用:ezsurfc('X.^2./8-Y.^2./6') 八、抛物柱面[X,Y]=m
8、eshgrid(-7:0.1:7);Z=Y.^2./8;h=mesh(Z);rotate(h,[101],180) %旋转处理%axis([-8,8,-8,8,-2,6]);ax