06.08.2013 Views

内容简介作者简介 - 科学与工程计算系

内容简介作者简介 - 科学与工程计算系

内容简介作者简介 - 科学与工程计算系

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

11.6.3.3 由包含绘图指令的 M 文件创建独立应用程序<br />

【例 11.6.3.3-1】考虑本文在 7.4.3.1 节中给出的模仿卫星返回地球时运动轨迹图的【例 7.4.3.1-<br />

2】中的代码。假设其中最后一行语句中的彗尾长要求用户输入,据此对原组代码修改,并<br />

将该组代码构成为一个 M 函数文件,如下:<br />

[exm110633_1.m]<br />

function exm110633_1<br />

shg;R0=1;<br />

a=12*R0;b=9*R0;T0=2*pi;<br />

T=5*T0;dt=pi/100;t=[0:dt:T]';<br />

f=sqrt(a^2-b^2);<br />

th=12.5*pi/180;<br />

E=exp(-t/20);<br />

x=E.*(a*cos(t)-f);y=E.*(b*cos(th)*sin(t));z=E.*(b*sin(th)*sin(t));<br />

plot3(x,y,z,'g')<br />

[X,Y,Z]=sphere(30);X=R0*X;Y=R0*Y;Z=R0*Z;<br />

grid on,hold on,surf(X,Y,Z),shading interp<br />

x1=-18*R0;x2=6*R0;y1=-12*R0;y2=12*R0;z1=-6*R0;z2=6*R0;<br />

axis([x1 x2 y1 y2 z1 z2])<br />

view([117 37]),<br />

p=input('Please input the comet'' length coeffient (the default value is 0.1): ');<br />

if ~isempty(p),<br />

p=0.1;<br />

end<br />

comet3(x,y,z,p),hold off<br />

mcc -B sgl exm110633_1<br />

mcc -B sglcpp exm110633_1<br />

11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!