If you want to use the odeNN functions you need to rewrite your 2 2nd-order ODEs into 4 1st-order ODEs, something like this:
function dxdydvxdvydt = your_eqs_of_motion(t,xyvxvy,other,parameters)
x = xyvxvy(1);
y = xyvxvy(2);
vx = xyvxvy(3);
vy = xyvxvy(4);
m = other;
Fx = force_functionx(t,x,y,vx,vy,other,parameters);
Fy = force_functiony(t,x,y,vx,vy,other,parameters);
dxdydvxdvydt = [vx;vy;Fx/m;Fy/m];
end
Then you can integrate the equations of motion something like this:
m = 12;
x0y0vx0vy0 = [1e-10,5.08e-5,0,0];
t_span = [0,2*pi];
[t_out,xyvxvy] = ode45(@(t,xyvxvy) your_eqs_of_motion(t,xyvxvy,m,[]),t_span,x0y0vx0vy0);
When integrating equations of motion you typically also have to carefully check that the constants of motion we know should be conserved (total energy, angular momentum, etc.) are reasonably conserved - the general ODE-integrating functions are not guaranteed to do this.
HTH
Best Answer