matlab课后习题及答案详解 联系客服

发布时间 : 星期四 文章matlab课后习题及答案详解更新完毕开始阅读0d6c15b00d22590102020740be1e650e52eacfb1

matlab课后习题及答案详解

出三维线图、网线图、表面图和带渲染效果的表面图。

>> [x,y]=meshgrid([-2:.2:2]); %产生\格点\矩阵 >> z=x.*exp(-x.^2-y.^2);

>> mesh(x,y,z) %网线图 >> subplot(2,2,1), plot3(x,y,z) %创建子图 >> title('plot3 (x,y,z)') >> subplot(2,2,2), mesh(x,y,z) >> title('mesh (x,y,z)')

>> subplot(2,2,3), surf(x,y,z) %三维着色表面图 >> title('surf (x,y,z)')

>> subplot(2,2,4), surf(x,y,z), shading interp %插值 >> title('surf (x,y,z), shading interp')

5.8 绘制peaks函数的表面图,用colormap函数改变预置的色图,观察色彩的分布情况。 >> surf(peaks(30)); %三维着色表面图

>> colormap(hot) %>> colormap(cool)

>> colormap(lines)

色图

matlab课后习题及答案详解

5.9 用sphere函数产生球表面坐标,绘制不通明网线图、透明网线图、表面图和带剪孔的表面图。 >> [x,y,z]=sphere(30); %产生球面 >> mesh(x,y,z)

>> mesh(x,y,z),hidden off

>> surf(x,y,z)

>> z(18:30,1:5)=NaN*ones(13,5); >> surf(x,y,z)

5.10 将5.9题中的带剪孔的球形表面图的坐标改变为正方形,以使球面看起来是圆的而不是椭圆的,然后关闭坐标轴的显示。

axis square axis off