资源描述:
《《matlab画三维》word版》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
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*
2、pi;i=1;h=plot3(sin(t(i)),cos(t(i)),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(
3、x,y,z,'h','linewidth',2);gridonaxis('square')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.^
4、2)./4') 三、椭圆柱面loadclownezsurf('(2*cos(u))','4*sin(u)','v',[0,2*pi,0,2*pi])view(-105,40) %视角处理shadinginterp %灯光处理colormap(map) %颜色处理gridon %添加网格线axisequal %使x,y轴比例一致xlabel('x轴');ylabel('y轴');zla
5、bel('z轴'); %添加坐标轴说明title('椭圆柱面') %添加标题四、椭圆抛物面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)*co
6、s(v)','8.*tan(u)*sin(v)','2.*sec(u)',[-pi./2,3*pi./2,0,2*pi])axisequalgridonaxissquarexlabel('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*ta
7、n(u)','v',[pi/2,3*pi/2,-3*pi,3*pi])colormap(map)shadinginterpview(-15,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
8、轴');zlabel('z轴');title('双曲抛物面')或直接用:ezsurfc('X.^2./8-Y.^2./6') 八、抛物柱面[X,Y]=meshgrid(-7:0.1:7);Z=Y.^2./8;h=mesh(Z);rotate(h,[101],180) %旋转处