实验6 图形绘制(3)
报告人: 王业成 年级: 机电131 学号: 2013012496 实验日期: 2015.4.27 报告完成日期: 2015.4.27 一、实验名称
图形绘制
二、实验目的:
熟悉MATLAB 的三维图形绘制函数。
三、实验内容:
subplot(2,2,1),sphere(3); title('n=3'),axis equal subplot(2,2,2), sphere(6); title('n=6'),axis equal subplot(2,2,3), sphere(10) title('n=10'),axis equal subplot(2,2,4), sphere(15); title('n=15'),axis equal
n=3
n=6
n=10
n=15
t=linspace(pi/2,3.5*pi,50);R=cos(t)+2; subplot(2,2,1);
cylinder(R,3), title('n=3'); subplot(2,2,2)
cylinder(R,6),title('n=6'); subplot(2,2,3)
cylinder(R),title('n=20') subplot(2,2,4)
cylinder(R,50),title('n=50')
[x,y]=meshgrid(-8:0.5:8,-10:0.5:10); R=sqrt(x.^2+y.^2)+eps; z=sin(R)./R; mesh(x,y,z);
n=3
n=6
n=20
n=50
x=-pi:0.15:pi; y=sin(x); subplot(2,1,1), H=bar(x,y); xx=get(H,'xdata'); yy=get(H,'ydata');
subplot(2,1,2),plot(xx,yy);
四、回答问题:
(回答实验指导书中提出的问题)
五、思考题:
1.试绘制出 2
2
2
2
)1(1)11)y ,x (f z y
x y
x +++
+-==的三维曲面图
和三视图
[x,y]=meshgrid(-1:0.1:1,-1:0.1:1); R=sqrt((1-x.^2)+y.^2)+eps; P=sqrt((1+x.^2)+y.^2)+eps; z=1./R+1./P; subplot(4,1,1) surf(x,y,z);
angle=[0,0;-90,0;0,90]; subplot(4,1,2) surf(x,y,z); z=1./R+1./P; view(angle(1,:)) title('主视图'); subplot(4,1,3) surf(x,y,z); z=1./R+1./P; view(angle(2,:)) title('左视图'); subplot(4,1,4) z=1./R+1./P; surf(x,y,z); view(angle(3,:)) title('俯视图');
2.绘出函数t
2
e t y ,sint x +==的慧星效果图。
x 1015
三维曲线
15主视图
-1
-0.8-0.6-0.4-0.200.2
0.40.60.8115
左视
图
-1
-0.8-0.6-0.4-0.200.20.40.60.81
俯视图
x=sin(t);
y=t.^2+exp(t);
figure(1)
comet(x,y);
figure(2)
plot(t,x,'k-',t,y,'k--');
title('The curves of x and y')
The curves of x and y
六、遇到的问题及解决:
三视图函数不知道,画有函数分析的图形时,不能确定函数变量的取值范围,在老师的指导下,知道了三视图函数是view,还有视角的情况,对于函数变量的取值范围,多练习多知识积累就可以学好的。
七、体会:
函数很多,但只要多看,多积累就可以很快学到很多知识,在写函数是也可以很快的调用自己想要的函数,还可以相互嵌套使用。