Hi

I have developed a NMPC controller for a simple wind turbine model using the `Matlab`

interface. And I been able to simulate a close loop simulation:

```
% simulation loop
for i_sim=1:n_sim
% select current state
x_ThisStep = x_sim(:,i_sim);
% solve ocp in every step if n_stage=n_step=1 or after each n_step*n_stage steps, starting at 1
if n_stage*n_step == 1 || mod(i_sim,n_step*n_stage) == 1
% init ocp
x_ocp_0 = x_ThisStep; % current state
if i_nmpc>1 % warm start
x_ocp_init = [x_ocp_opt(:,n_stage+1:end),repmat(x_ocp_opt(:,end),1,n_stage)];
u_ocp_init = [u_ocp_opt(:,n_stage+1:end),repmat(u_ocp_opt(:,end),1,n_stage)];
end
p_ocp = p_nmpc (:,:,i_nmpc);
% solve ocp
[x_ocp_opt,u_ocp_opt,ocp] = SolveOcp(x_ocp_0,x_ocp_init,u_ocp_init,p_ocp,x_cond,u_cond,ocp);
% store nmpc results
x_nmpc(:,:,i_nmpc) = x_ocp_opt;
u_nmpc(:,:,i_nmpc) = u_ocp_opt;
% update counters
i_nmpc = i_nmpc+1;
i_stage = 0;
end
% Update i_stage in every step if n_step=1 or after each n_step, starting at 1
if n_step == 1 || mod(i_sim,n_step) == 1
i_stage = i_stage+1;
end
% select current input and parameter
u_ThisStep = u_ocp_opt(:,i_stage);
p_ThisStep = p_sim(:,i_sim);
% solve sim
[x_NextStep] = SolveSim(x_ThisStep,u_ThisStep,p_ThisStep,x_cond,u_cond,sim);
% store simulation results
u_sim(:,i_sim) = u_ThisStep;
x_sim(:,i_sim+1) = x_NextStep;
```

With the expected results. And I would like to do the same using `Simulink`

.

To do so, I have checked the example located here `acados\examples\acados_matlab_octave\getting_started\simulink_example.m`

After checking the example I have compiled the code using the following commands:

```
%% Simulation model and OCP objects
sim = acados_sim(sim_model, sim_opts);
ocp = acados_ocp(ocp_model, ocp_opts);
%% Render templated Code for the model contained in ocp object
%
ocp.generate_c_code;
%% Compile Sfunctions
cd c_generated_code
make_sfun; % ocp solver
make_sfun_sim; % integrator
```

Then I just call the generated code like it is done on the example.

However, when I use the same `inputs`

from my `script`

code the `Simulink`

is not performing as expected. And I cannot find any reason to itâ€¦

Does anyone know what could be the issue? Any help would be welcomed

Thanks in advance

Javier