MATLAB Answers

Ode45 with 3 non-linear equations

1 view (last 30 days)
Ahmed Alagha
Ahmed Alagha on 28 Apr 2021
Answered: David Goodmanson on 28 Apr 2021
Hello,
I have the following system of 3 diiferential equations.
I am trying to solve it using ode45 in MATLAB but I'm struggling to define the state space variables. This mainly because each equation contains 2 or 3 variable in 2nd derivative form.
How can I deal with this? Any help is appreciated :D

Answers (1)

David Goodmanson
David Goodmanson on 28 Apr 2021
Hi Ahmed,
it might be a good idea to go back to the original derivation for this system. Instead of that, you can rewrite this as a matrix equation
[(M+m) m*sin(theta) m*r*cos(theta)] [ y''] [A1]
[ m*sin(theta) m 0 ] [ r''] = [A2]
[ m*cos(thea) 0 m*r ] [theta''] [A3]
where the notation means matrix * column vector = column vector. Each row corresponds to an equation and says that some combination of y'',r'',theta'' equals some other terms. Here A1 is the sum of all the stuff in eqn 1 not involving y'',r'',theta'', taken over to the right hand side. SImilarly for A2 and A3. Each of A1,A2,A3 might involve y,y',r,r',theta,theta'.
For the input to ode45, y,r, and theta are presumed known. Three of the required ode45 equations are
ydot = d/dt y
rdot = d/dt r
thetadot = d/dt theta
so the state variables are effectively known. This means that A1,A2,A3 and the matrix are all known. Denoting the matrix as B, then
[ y''] [A1]
B [ r''] = [A2]
[theta''] [A3]
so
[ y''] [A1]
[ r''] = B \ [A2]
[theta''] [A3]
and the last three required equations are
[ dydot / dt] [A1]
[ drdot / dt] = B \ [A2]
[dthetadot / dt] [A3]

Tags

Products

Community Treasure Hunt

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

Start Hunting!