Exploit Model Predictive Control function that I made in a Simulink control loop

1 view (last 30 days)
Hello everyone, i am trying to port a code that i already implemented in matlab that basically solve an mpc problem (exploiting quadprog) with a switching model based on regression trees.
I am using a simulink to loop the system because i have systems' blocks already implemented but i want to substitute the original PID block with my personal block that implements the code that i already have.
My code is already implemented in a matlab function that takes as inputs parameters and models, does some pre computations and finally exploiting quadprog, find an optimal control that is returned by the function, something like this: [control]=SWMPC(state, models, parameters). My idea was to
1) initially load models and parameters in the workspace
2) run the simulink model with a block containing SWMPC
3) apply the control computed by the block.
I thought it was easy, but i'm having many issues becuase the models that i have, are based on cellarrays and apparently when i pass them to the simulink block containing all the lines that implement my control it returns me problems.
Have you had similar issues? Do you have any suggestions?
Thanks to all of you guys!

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!