how to solve this coupled ODE problem using ode solvers ?

1 次查看(过去 30 天)
I have two ODEs within time interval [0 1] with initial conditions values for F_x and F_y are calculated from function

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2021-1-20
编辑:Bjorn Gustavsson 2021-1-20
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); % If my ode-equations are complicated
y = xyvxvy(2); % I prefer to explicitly extract the
vx = xyvxvy(3); % variables into something that's
vy = xyvxvy(4); % easily human-readable
m = other;
Fx = force_functionx(t,x,y,vx,vy,other,parameters); % Adjust inputs as necessary
Fy = force_functiony(t,x,y,vx,vy,other,parameters);
% or possibly preferable:
% [Fx,Fy] = force_function_xny(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; % you know what to set for this one
x0y0vx0vy0 = [1e-10,5.08e-5,0,0]; % Your initial conditions
t_span = [0,2*pi]; % a time-span of interest
[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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by