Simulation of Sun-Earth system in MATLAB | M-file

Code:



clc
clear all
close all
t=0:0.03:2*pi;
x=-6+cos(t);
y=sin(t);
esa=fill(0.2*x,0.2*y,'y');
hold on;
x=2*cos(t);
y=sin(t);
plot(x,y,'b--');
axis square;
hold on;
x=[x x x x x x x x x x x x x x x];
y=[y y y y y y y y y y y y y y y];
for i=1:length(x)
    e=x(i)+0.1*cos(t);
    f=y(i)+0.1*sin(t);
    h=fill(e,f,'b');
    axis([-4 4 -4 4]);
    drawnow
    delete(h);
end

No comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();