% BRIEF RECAP of November 12th, 1998 NEEP271 lecture
% written by Fabian Waleffe 98/11/12
%
% INITIAL VALUE PROBLEMS continued
%
% we downloaded ODE1.m, ORBIT.m and wrote functions f(t,y) 
% for various systems (f(t,y)=cos(t*y) and a stiff system)
% then we tried them out together with Matlab's powerful
% ODE23

type ode1     % just checking you've got those!
type orbit

[t,y]=ode1('exptest',[0 1],1,20);   plot(t,y)

% here is the orbit example:

t0=0; tf=60*60*24*2; y0=[-2e7;0;0;5000];

[t,y]=ode23('orbit',[t0 tf],y0);

plot(y(:,1),y(:,2))

% Let's show the earth at 0,0

hold on, plot(0,0,'o'), hold off

% Let's try Euler with 100 and 1000 steps on this:

[te1,ye1]=ode1('orbit',[t0 tf],y0,100);

plot(y(:,1),y(:,2),ye1(:,1),ye1(:,2),0,0,'o'), pause(3)

[te2,ye2]=ode1('orbit',[t0 tf],y0,1000);

plot(y(:,1),y(:,2),ye1(:,1),ye1(:,2),ye2(:,1),ye2(:,2),0,0,'o')
pause(2)
axis image

% Once again, Euler works but it takes pretty small steps if you
% do not want to get lost in space...
