上机习题6 MATLAB7.0三维绘图.doc

PAGE PAGE 1 实验六 MATLAB7.0三维绘图 实验目的: ① 掌握绘制三维图能形的方法; ② 掌握图形修饰处理方法; = 3 \* GB3 ③ 知道图像处理方法,了解动画制作方法。 实验要求:给出程序和实验结果。 实验内容: 一、绘制三维曲线 t=0:pi/100:20*pi; x=sin(t); y=cos(t); z=t.*sin(t).*cos(t); plot3(x,y,z); title(Line in 3-D Space); xlabel(X);ylabel(Y);zlabel(Z); grid on; 二、绘制三维曲面图z=sin(x+sin(y))-x/10。 [x,y]=meshgrid(0:0.25:4*pi); z=sin(x+sin(y))-x/10; mesh(x,y,z); axis([0 4*pi 0 4*pi -2.5 1]); 三、绘制z=x2+y2的三维网线图形; x,y]=meshgrid(0:0.25:4*pi); z=x.^2+y.^2; mesh(x,y,z) 四、绘制三维陀螺锥面; (仅供参考: t1=0:0.1:0.9; t2=1:0.1:2; r=[t1 -t2+2]; [x,y,z]=cylinder(r,30); surf(x,y,z); grid ) t1=0:0.1:0.9; t2=1:0.1:2; r=[t1 -t2+2]; [x,y,z]=cylinder(r,30); surf(x,y,z); grid 五、在xy平面内选择区域[-8,8]×[-8,8],利用mesh、meshc、meshz和surf绘制。要求用子图在一个图形窗口中绘制。 [x,y]=meshgrid(-8:0.5:8); z=sin(sqrt(x.^2+y.^2))./sqrt(x.^2+y.^2+eps); subplot(2,2,1); mesh(x,y,z); title(mesh(x,y,z)) subplot(2,2,2); meshc(x,y,z); title(meshc(x,y,z)) subplot(2,2,3); meshz(x,y,z) title(meshz(x,y,z)) subplot(2,2,4); surf(x,y,z); title(surf(x,y,z)) 六、绘制光照处理后的球面,取三个不同的光照位置进行比较。(提示:可以利用函数sphere和 light) [x,y,z]=sphere(20); subplot(1,2,1); surf(x,y,z);axis equal; light(Posi,[0,1,1]); shading interp; hold on; plot3(0,1,1,p);text(0,1,1, light); subplot(1,2,2); surf(x,y,z);axis equal; light(Posi,[1,0,1]); shading interp; hold on; plot3(1,0,1,p);text(1,0,1, light); 七、利用peaks产生数据,绘制多峰曲面图。 [X,Y,Z]=peaks(27); subplot(1,2,1); mesh(Z) subplot(1,2,2); surf(Z) 八. ,当x和y的取值范围均为-2到2时,用建立子窗口的方法在同一个图形窗口中绘制出三维线图、网线图、表面图和带渲染效果的表面图。 [x,y]=meshgrid([-2:0.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) 九 绘制peaks函数的表面图,用colormap函数改变预置的色图,观察色彩的分布情况。 surf(peaks(30)) colormap(hot) colormap(cool) colormap(lines) 十、 用sphere函数产生球表面坐标,绘制不透明网线图、透明网线图、表面图和带剪孔的表面图。 [x,y,z]=sphere(30); mesh(x,y,z) [x,y,z]=sphere(30); mesh(x,y,z) hidden off surf(x,y,z) z(18:30,1:5)

文档评论(0)

1亿VIP精品文档

相关文档