How to solve a first order ODE system with coupled equations
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
shaunaksinha
il 10 Ott 2018
Commentato: shaunaksinha
il 10 Ott 2018
Hello,
I have a system of equations describing a double pendulum on a cart as described below.
</matlabcentral/answers/uploaded_files/135839/double_pendulum.png> My aim is to solve the equation numerically using ode45. I have defined the state vector
y=[x, theta1, theta2, x_dot, theta1_dot, theta2_dot]
=[y1, y2, y3, y4, y5, y6]
to transform the 2nd order equations into a system of 1st order equations. After expanding the terms, I get the following 1st order equations:
1> dy1/dt = y4
2> dy2/dt = y5
3> dy3/dt = y6
4> dy4/dt = {f - [0.75cos(y2)*dy5/dt + 0.25cosy3*dy6/dt - 0.75(y5^2) * sin(y2) - 0.25(y6^2)* sin(y3)]}/2
5> dy5/dt = -[0.75cos(y2)*dy4/dt + 0.25cos(y2-y3)*dy6/dt + 0.25(y6^2)*sin(y2-y3) - 7.3575*sin(y2)]/0.67
6> dy6/dt = -[0.25cos(y3)*dy4/dt + 0.25cos(y2-y3)*dy5/dt - 0.25(y5^2)*sin(y2-y3) - 2.4525sin(y3)]/0.16
I have substituted all the constants to make the equations easy to read. The equations 4,5 and 6 above have 1st order terms on LHS and RHS so I am unsure how to use ode45 and solve the system.
Thank you!
0 Commenti
Risposta accettata
James Tursa
il 10 Ott 2018
Modificato: James Tursa
il 10 Ott 2018
If you have these dependencies among the dy4/dt, dy5/dt, and dy6/dt terms, then you need to first solve for them uniquely. Just consider those last three equations as a linear system of equations for dy4/dt, dy5/dt, and dy6/dt with everything else known. I.e., at that point in the code you know all of the other values in the equations so you could plug them in. Collect all of the coefficients on these terms to give you three linear equations to solve for the values of dy4/dt, dy5/dt, and dy6/dt. You could use backslash \ for this.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!