《MATLAB畫三維圖》由會員分享,可在線閱讀,更多相關(guān)《MATLAB畫三維圖(5頁珍藏版)》請在裝配圖網(wǎng)上搜索。
1、MATLAB畫三維函數(shù)圖下面將這幾天所做的圖像及程序小記一下望大蝦指教一、螺旋線1 .靜態(tài)螺旋線a=0:0.1:20*pi;h=plot3a.*cos,a.*sin,2.*a,b,linewidth,2;axis;gridonset;xlabel;ylabel;zlabel;title;2 .動態(tài)螺旋線t=0:0.1:10*pi;i=1;h=plot3sint,cost,t,*,erasemode,none;gridonaxisfori=2:lengthseth,xdata,sint,ydata,cost,zdata,t;drawnowpauseendtitle;3 .圓柱螺旋線t=0:0.1
2、:10*pi;x=r.*cos;y=r.*sin;z=t;plot3;gridonaxisxlabel;ylabel;zlabel;title二、旋轉(zhuǎn)拋物面b=0:0.2:2*pi;X,Y=meshgrid;Z=./4;meshc;axisxlabelvx軸;ylabel;zlabel;title或直接用:ezsurfc./4三、橢圓柱面loadclownezsurf2*cos,4*sin,v,0,2*pi,0,2*piviewshading interp %colormapgrid onaxis equalxlabel;ylabelytitle四、橢圓拋物面b=0:0.2:2*pi;X,Y=
3、meshgrid;Z=X.A2./9+Y.A2./4;meshc;axisxlabel;ylabelytitle% 視角處理燈光處理% 顏色處理% 添加網(wǎng)格線% 使 x,y 軸比例一致軸 ;zlabel;% 添加標(biāo)題軸 ;zlabel;% 添加坐標(biāo)軸說明或直接用:ezsurfc五、雙葉雙曲面ezsurf8*tan*cos,8.*tan*sin,2.*sec,-pi./2,3*pi./2,0,2*piaxisequalgridonaxissquarexlabel;ylabel;zlabel;title六、雙曲柱面loadclownezsurf2*sec,2*tan,v,-pi/2,pi/2,-3
4、*pi,3*pihold on%在原來的圖上繼續(xù)作圖ezsurf2*sec,2*tan,v,pi/2,3*pi/2,-3*pi,3*picolormapshadinginterpviewaxisequalgridonaxisequalxlabel;ylabel;zlabelz軸title七、雙曲拋物面馬鞍面X,Y=meshgrid;Z=XA2./8-YA2./6;meshc;viewaxisxlabel;ylabel;zlabelz軸title或直接用:ezsurfc八、拋物柱面X,Y=meshgrid;Z=YA2./8;h=mesh;rotate%旋轉(zhuǎn)處理%axis;axisxlabelx軸
5、NylabeKy軸RzlabelvN軸title或直接用:ezsurfc九、環(huán)面ezmesh5+2*cosu*cos,5+2*cosu*sin,2*sin,0,2*pi,0,2*piaxisequalgridonxlabel;ylabel;zlabelz軸title十、橢球ezsurfc5*cos*sin,3*sin*sin,4*cos,0,2*pi,0,2*piaxisequalgridonxlabel;ylabel;zlabel;title十一、單葉雙曲面ezsurf4*sec*cos,2.*sec*sin,3.*tan,-pi./2,pi./2,0,2*piaxisequalgridon
6、xlabel;ylabel;zlabel;title十二、旋轉(zhuǎn)單葉雙曲面loadclownezsurf8*sec*cos,8.*sec*sin,2.*tan,-pi./2,pi./2,0,2*picolormapview%alpha%透明處理axisequalgridonaxissquarexlabel;ylabel;zlabel;title十三、圓柱面subplotezsurf2*cos,2*sin,v,0,2*pi,0,2*pigridonshadinginterpaxisequalxlabel;ylabel;zlabel;titlesubplotcylindershadinginterpaxissquaretitle下面給出用colormap改變圖像顏色的例子:colormap;%hot/cool/copper/gray/hsv/spring/summer/winter.colormapcolormapcolormapcolormapcolormap下面做了旋轉(zhuǎn)view、燈光shadinginterp、透明alpha處理: