怎么用matlab 做一个地球围绕太阳的模型
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 08:17:11
怎么用matlab 做一个地球围绕太阳的模型
怎么用matlab 做一个地球围绕太阳的模型
怎么用matlab 做一个地球围绕太阳的模型
t=linspace(0,2*pi,100);
fill(cos(t),sin(t),'r');
hold on;
plot(4*cos(t),sin(t)*4,'k');
set(gca,'position',[0 0.11 0.775 0.815])
a=0.1;b=0;
xe=4*cos(a)+cos(t)*0.6;
ye=4*sin(a)+sin(t)*0.6;
He=fill(xe,ye,'b');
xm=4*cos(a)+cos(b);
ym=4*sin(a)+sin(b);
set(gcf,'doublebuffer','on');
Hm=plot(xm,ym,'c.','markersize',24);
aa=gca;
axis([-6,6,-6,6]);
axis square;
k=1;da=0.1;db=0.5;
xlabel('Please press "space" key and stop this program!',...
'fontsize',12,'color','r');
title('simulate solar system')
axes('position',[0.75,0.11,0.25,0.8]);
fill(0.2+cos(t)*0.18,0.75+sin(t)*0.08,'r');
ylim([0,1]);xlim([0,0.9]);
text(0.5,0.75,'Sun');hold on;
fill(0.2+cos(t)*0.11,0.5+sin(t)*0.05,'b');
text(0.5,0.5,'Earth');
plot(0.2,0.3,'c.','markersize',24);
text(0.5,0.3,'Moon');
axis off
axes(aa);
while k;
s=get(gcf,'currentkey');
if strcmp(s,'space');
clc;k=0;
end
a=a+da;
b=b+db;
xe=4*cos(a)+cos(t)*0.6;
ye=4*sin(a)+sin(t)*0.6;
xm=4*cos(a)+cos(b);
ym=4*sin(a)+sin(b);
set(He,'xdata',xe,'ydata',ye);
set(Hm,'xdata',xm,'ydata',ym);
pause(0.1);
if a
http://zhidao.baidu.com/question/96341003.html