# Simulink model from a nonlinear State Space

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

u is the input and y is the output.

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

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

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


Exactly for this case we published a small tool that enables to generate simulink models: ODESCA TOOL (Github)