Solving a System of 2nd Order Nonlinear ODEs

4 views (last 30 days)
mpz on 2 Apr 2022
Commented: mpz on 3 Apr 2022
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.
clear all;clc
function dydt=mbd(M,m,g,lc,k)
z1=z(1); %z1
z2=z(2); %z2
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))));

Accepted Answer

Sam Chak
Sam Chak on 3 Apr 2022
Hey @mpz
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 5:
Equation 6:
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.

Sign in to comment.

More Answers (1)

Alan Stevens
Alan Stevens on 3 Apr 2022
You haven't passed y and z to the funcion in
function dydt=mbd(M,m,g,lc,k)
Probably needs to be more like
function dydt=mbd(t,y,z,M,m,g,lc,k)
with the calling function modified accordingly.

Community Treasure Hunt

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

Start Hunting!

Translated by