Solving a System of 2nd Order Nonlinear ODEs
4 views (last 30 days)
Hi, I need help with setting up the code for the below 2 non-linear differential equations. I do not have symbolic toolbox. Below is how I tried it but didn't work. Any help will be appreciated.
y5=(1/(M+m))*((m*l/2)*(sin(z(1)))*y6 + (m*l/2)*(cos(z(1)))*(z(2))^2 ...
y6=(3/(m*l^2))*((m*l/2)*(sin(z(1)))*y5 - (m*g*l/2)*(sin(z(1))));
Sam Chak on 3 Apr 2022
It doesn't work that way because you have created an algebraic loop error where depends y5 that is your , which depends on y6 that is from the beginning.
I'll try to explain how to solve it without using difficult math or matrix operations. Here, the governing equations are given by
Equation 6 can be rearranged to become
so that it can substituted into Equation 5 to eliminate
and then be simplified to become
... Equation (7).
Note the the right-hand side of Equation 7 does not have the term . Subtituting Equation 7 into the simplified Equation 6 yields
... Equation (8).
Now you can rewrite the mbd ode function in state-space form correctly. Note that the ODEs should have only 4 states (instead of 6 states):
If you find my technical explanation is helpful, please vote and accept the answer.
More Answers (1)
Alan Stevens on 3 Apr 2022
You haven't passed y and z to the funcion in
Probably needs to be more like
with the calling function modified accordingly.