当前位置:文档之家› 数学实验 第四章

数学实验 第四章

第四章练习题
(1)t=0:0.01:20;
x=exp(-0.2*t).*cos(pi/2*t);
y=pi/2*sin(t);
z=t;
plot3(x,y,z,'r');
(2)a=1;
t=-pi:0.01:pi;z=t;
x=a*(cos(t)).^3;
y=a*(sin(t)).^3;
plot3(x,y,z,'r');
(3)a=1;b=1;
t=0:0.01:2*pi;z=t;
x=a*(t-sin(t));
y=b*(1-cos(t));
plot3(x,y,z,'r');
(4)t=-pi:0.01:pi;
x=2*sin(t);
y=cos(t);
z=4*t;
plot3(x,y,z,'r');
(5)t=0:0.01:2*pi;
x=cos(5*t);
y=sin(3*t);
z=sin(t);
plot3(x,y,z,'r');
(6)[X,Y]=meshgrid([-30:0.3:30]);
r=X.^2+Y.^2;
Z=10*sin(sqrt(r))./(sqrt(1+r));
subplot(3,1,1),contour(X,Y,Z,20),title('等高线图');
grid on;
subplot(3,1,2),contour3(X,Y,Z,20),title('三维等高线图');
grid on;
subplot(3,1,3),meshc(X,Y,Z),title('三维图');
grid on;
(7)t=-1:0.1:1; [x,y]=meshgrid(t); z=x.^2+y.^2;
subplot(2,1,1),mesh(x,y,z),title('网格图');
subplot(2,1,2),surf(x,y,z),title('表面图');
(8)先将此方程化为参数方程:
4sin cos 9sin sin cos x y z ϕθϕθϕ=⎧⎪
=⎨⎪=⎩
其代码如下:
[phy,sita]=meshgrid([0:0.1:pi],[0:0.1:2*p i]);
x = 4*sin(phy).*cos(sita); y = 9*sin(phy).*sin(sita); z = cos(phy);
mesh(x,y,z),title('椭球面');
(9)
[t,u]=meshgrid([0:0.01:2*pi],[0:0.01:2*p i]);
x=cos(t).*(3+cos(u)); y=sin(t).*(3+cos(u)); z=sin(u); mesh(x,y,z);
(10)
[u,v]=meshgrid([0:0.01:2],[0:0.01:2*pi]); x=u.*cos(v);
y=u.*sin(v);
z=u.^2;
mesh(x,y,z);
思考与提高
1.t=-1:0.1:1;
[x,y]=meshgrid(t);
z=x.^2-2*y.^2;
mesh(x,y,z),title('马鞍形状');
2.①建立fun函数:
function dy=fun(x,y)
dy=x.*y;
②写M文件
clc,clear
a=0;b=4;c=0;d=4;n=15;
[X,Y]=meshgrid(linspace(a,b,n),linspace( c,d,n));
z=X.*Y;
fx=cos(atan(X.*Y));
fy=sqrt(1-fx.^2);
quiver(X,Y,fx,fy,0.5,'k'),hold
on,axis([a,b,c,d])
[x,y]=ode45('fun',[0,4],0.4);
plot(x,y,'r.-') 运行结果:
验证性实验 实验一空间曲线
1. t=0:0.01:10*pi; x=sin(t);y=cos(t);z=t;
subplot(2,1,1);plot3(x,y,z,'r'); t=0.1:0.01:1.5;
x=cos(t);y=sin(t);z=1./t;
subplot(2,1,2);plot3(x,y,z,'r');
2.首先把方程组化为以下形式:
x t y z ⎧=⎪⎪
=⎨⎪=⎪⎩
于是其代码为: t=0:0.01:1;
x=t;y=sqrt(t.*(1-t)); z=sqrt(1-x.^2-y.^2); plot3(x,y,z,'r');
3.t=0:0.1:10*pi;
x=t;y=sin(t);z=sin(2*t); plot3(x,y,z,'r');
4.t=0:0.1:10*pi;
x=sin(t);y=sin(2*t);z=sin(3*t); plot3(x,y,z,'r');
实验二二次曲线
1.x=-4:0.5:4;
y=x;
[X,Y]=meshgrid(x,y);
z=(1+X+Y).^2;
mesh(X,Y,z);
2.x=-4:0.5:4;
y=x;
[X,Y]=meshgrid(x,y);
z=X.^2+Y.^2;
mesh(X,Y,z);
3.
x=-4:0.4:4;
z=1./(x.^3-2*x+4);
[X,Y,Z]=cylinder(z,60);
mesh(X,Y,Z);
4.
[x,y]=meshgrid(-3:0.2:3,-3:0.2:3);
z=sin(x+sin(y));
subplot(2,1,1),plot3(x,y,z),title('空间图形'); t2=-10:1:10;
[x2,y2]=meshgrid(t2);
z2=x2.^2-2*y2.^2;
subplot(2,1,2),mesh(x2,y2,z2),title('马鞍面');
5.
t=-8:0.1:8;
[x,y]=meshgrid(t);
r=sqrt(x.^2+y.^2);
z=sin(r)./r;
subplot(1,3,1),meshc(x,y,z),title('meshc' );
subplot(1,3,2),meshz(x,y,z),title('meshz')
;
subplot(1,3,3),mesh(x,y,z),title('mesh');
6.
t=-1:0.1:1;
[x,y]=meshgrid(t);
z=3-x.^2-y.^2;
subplot(2,1,1),mesh(x,y,z),title('网格图
');
subplot(2,1,2),surf(x,y,z),title('表面图');
7
v=[-2,2,-2,2,-2,2];
subplot(2,1,1),sphere(20),title('半径为1的球面'),axis(v); [x,y,z]=sphere(20);
subplot(2,1,2),surf(2*x,2*y,2*z),title('半径为2的球面'),axis(v);
t=-1:0.1:1;
subplot(2,1,1),cylinder(1,50),title('柱面');
subplot(2,1,2),cylinder(sqrt(abs(t)),50),title('旋转面');
设计性实验
实验一地球表面的气温分布
[a,b,c]=sphere(40);
t=max(max(abs(c)))-abs(c);
surf(a,b,c,t),title('气温分布图');
axis('equal');
colormap('hot');
shading flat,colorbar;
实验二路线的设计
[X,Y]=meshgrid([-400:40:400]);
Z=320-(X.^2+Y.^2)/50;
subplot(2,1,1),contour(X,Y,Z,13),title('等高线图'); grid off;
subplot(2,1,2),contour3(X,Y,Z,11),title('三维图'); grid off;。

相关主题