How to use ODE solver for a coupled second order ODE?
2 views (last 30 days)
Show older comments
I have two coupled ODEs that I'm trying to solve with ODE45. They are of the form Ay'' + Bx'' + Cy' + Dy - Esin(x) = 0 and Fx'' + Gy'' + Hx' + Ix - Jsin(x) = 0. How do I get them into a form that can be used by Matlab?
0 Comments
Answers (1)
Are Mjaavatten
on 11 Dec 2017
Convert to four first-order ODEs in x, u,y,v, where u = x', v = y'.
The equations are then:
A*u' + B*v' = -C*v - D^y + E*sin(x)
F*v' + G*u' = -H*u + I^x + J*sin(x)
x' = u
y' = v
If z = [x,y,u,v]', then your function for the right-hand side of the ODE may look something like this:
function dz = rhs(z)
M = [0,0,A,B;0,0,F,G;1,0,0,0;0,1,0,0];
N = [0,D,0,C;I,0,H,0;0,0,1,0;0,0,0,1];
dz = -M\N*z + [E;J;0;0]*sin(z(1));
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!