Filter löschen
Filter löschen

How to use ODE solver for a coupled second order ODE?

1 Ansicht (letzte 30 Tage)
Pieter Boersma
Pieter Boersma am 11 Dez. 2017
Beantwortet: Are Mjaavatten am 11 Dez. 2017
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?

Antworten (1)

Are Mjaavatten
Are Mjaavatten am 11 Dez. 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));

Community Treasure Hunt

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

Start Hunting!

Translated by