Dear Johan,
I am currently working on building an MPC controller (based on LMIs). I started with a very simple model without uncertainties. In the m-file 'simulation' this simulation can be found and seems to work fine.
Although, I also want to build the MPC controller in Simulink. I have done this by adapting the model from the Standard MPC tutorial in Simulink (the fastest). However, when I run the simulation, the system is instable and 'explodes'. It already goes wrong with the first calculation of u. The input should increase at first, but as can be seen in the scope, this is not the case.
I have no idea what the cause of this can be. The parameters in both files are all the same. The reference is set to 0 and the initial condition of the states is [0.05; 0];
I hope you can tell me what is wrong, and why the controller seems to work perfectly when simulating in an m-file, but does almost the opposite when using Simulink.
I have attached all nescessary files.
Thanks you in advance!
kind regards, Laura
[L,P] = dlqr(Ad,Bd,Cd'*Q*Cd,R)
objective = objective + x{end}'*P*x{end};
P
1.0e+06 *
2.3404 0.1233
0.1233 0.0123
>> tf(d2c(ss(A,B,C,0,.1)))
ans =
-0.04219 s + 0.8292
-------------------
s^2 + 1.054 s