[Math] Simulink model from a nonlinear State Space

control theoryMATLABsimulink

I have the nonlinear state space already constructed in MuPAD as shown:

nonlinear state space

u is the input and y is the output.

What is the best way for me to take this to Simulink?

Best Answer

I would not use Simulink for simulating the system. But just use plain matlab code and the ODE solver...

Read about it: http://nl.mathworks.com/help/matlab/math/ordinary-differential-equations.html

It would look something like...

time       = 0:0.01:5;
x0         = [0 0 0 0];
odeOptions = odeset('RelTol',1e-6,'AbsTol',[1e-8 1e-8]);
u          = sin(time);
[t,y]      = ode45(@system,time,x0,odeOptions,u);

And then in your ODE function system you define your (non)linear system.

function dxdt = system(t,x,u)
dxdt = [x(2); ...
        -7.01*sin(x(3)) + (0.163*x(4) - 0.00816*u - 4.0e-6*sin(x(3)) + ...;
        x(4); ...
        -(400/7*x(4) - 20/7*u - ...];
end
Related Question