How do I add in external equations in ODE45 simulation?

1 view (last 30 days)
Hello!
This is my state space model:
// State space
der(x1) = x2;
m1*der(x2) = -k1*(x1 - x3) + Pp*Ap*10 - Pm*Am*10 -b1*(x2 - x4) - gamma*x2;
der(x3) = x4;
M*der(x4) = k1*(x1 - x3) - k2*(x3 - L2*sin(x5)) + b1*(x2 - x4) - M*g*mu*x4;
der(x5) = x6;
1/3*m2*L2^2*der(x6) = L2*k2*(x3 - L2*sin(x5)) - k3*x5 - b2*x6 + L2/2*m2*g*sin(x5);
And this is my external functions who gives values to the state space model. How do I include this inside the ODE45 function?
// Dynamic flow
Qin = 15*R1*sqrt(P - Pp);
// Dynamic pressure
Pp = beta/(Ap*x1)*(Qin - 6*Ap*x2);
Pm = beta/(Am*(L1 - x1))*(6*Am*x2 - 6*Am*x2*R2);
This is probably very easy to do, but I don't know how to do that.
  2 Comments
Star Strider
Star Strider on 24 May 2017
That does not look like MATLAB syntax.
Please post your MATLAB code.
Daniel
Daniel on 24 May 2017
I don't have a MATLAB code. This is a OpenModelica code. The only who differ is the der() command. der() is the derivative.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!