实验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=310-10.50-0.5-0.8-0.6-0.4-0.200.20.4n=1010-10.51-0.500-1 1
n=610-10.501-0.50-1n=1510-10.50-0.500.5-0.5
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')
n=310.5050-5-5n=2010.5050-5-5010.5050-5-50010.5050-5-5n=500n=65555[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);
10.50-0.51050-5-10-10-55010
2
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);
10.50-0.5-1-410.50-0.5-1-4-3-2-101234-3-2-101234
四、回答问题:
(回答实验指导书中提出的问题)
五、思考题:
1.试绘制出 z?f(x,y)?和三视图
[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);
3
11?x)?y22?1(1?x)?y22的三维曲面图
title('三维曲线')
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('俯视图');
x 105010.5x 101515三维曲线0-0.5-1-1主视图-0.500.5150-15x 10-0.815-0.6-0.4-0.20左视图0.20.40.60.8101010.80.60.40.20-0.2俯视图-0.4-0.6-0.8-1-1-1-0.8-0.6-0.4-0.200.20.40.60.81
2.绘出函数x?sint,y?t?e的慧星效果图。
2t 4
t=0:0.01:2*pi; 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 y6005004003002001000-10001234567
六、遇到的问题及解决:
三视图函数不知道,画有函数分析的图形时,不能确定函数变量的取值范围,在老师的指导下,知道了三视图函数是view,还有视角的情况,对于函数变量的取值范围,多练习多知识积累就可以学好的。 七、体会:
函数很多,但只要多看,多积累就可以很快学到很多知识,在写函数是也可以很快的调用自己想要的函数,还可以相互嵌套使用。
5
相关推荐: