MATLAB Answers

Solving nonlinear system of ode in Simulink

8 views (last 30 days)
Tom on 14 Sep 2021
Commented: Tom on 15 Sep 2021
I am trying to solve a system of nonlinear equations of motion in Simulink, where
x = [x1...x7] is the system state with the derivatives xdot = [x1dot...x7dot] and xdotdot = [x1dotdot...x7dotdot],
p = [] are parameters (partly non constant) and
u = [u1...u3] is the system input.
All 7 equations are nonlinear, e.g.
p2*x2dotdot - p3*x3dotdot + p4*x4dotdot + p5*x4dot*x5dot - p6*x5 + p7 + u1 = 0;
As a result of this form, the second derivatives depend on another. This leads to a set of equations
x1dotdot = f1(p,u,x,xdot)
x2dotdot = f2(p,u,x,xdot,x3dotdot,x4dotdot,x5dotdot)
x3dotdot = f3(p,u,x,xdot,x2dotdot,x4dotdot,x5dotdot)
x4dotdot = f4(p,u,x,xdot,x2dotdot,x3dotdot,x5dotdot)
What I have tried so far is implementing the equations in a simulink model without changing their form. By adding unit delays I solved the equations based on the previous xdotdot.
Another way I tried was by solving the equations for x and xdot using the solve function to get a system of the form xdotdot = f(p,u,x,xdot). Based on this, I tried to change the system to a first order system by expanding x to [x, xdot].
However, all of these tries have lead to bad results (values getting very large + stepsize errors).
How should I go about solving these equations where the derivatives depend on another?

Answers (1)

Paul on 14 Sep 2021
The best way IMO is to get the equations in the form xdotdot = f(p,u,x,xdot), which you already did. But what did you mean by "expanding x to [x, xdot]."? Once you have the equations in the desired form, they are implemented using either two Integrator blocks in series to integrate from xdotdot to xdot and from xdot to x. The integrator outputs, xdot and x respectively, feed back into the calculation of xdotdot. Or, instead of two integrators, one can use an Integrator, Second Order block.
Tom on 15 Sep 2021
Thanks! I'll try this out and report my findings when I'm done

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!