How to solve a first order ODE system with coupled equations

1 次查看(过去 30 天)
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!

采纳的回答

James Tursa
James Tursa 2018-10-10
编辑:James Tursa 2018-10-10
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by