Simulink: How to run a subsystem only once per time step regardless of solver?
6 views (last 30 days)
Show older comments
José Felgueiras
on 11 Sep 2020
Answered: Mrunmayee Gaikwad
on 8 Oct 2020
Hello,
I am implementing a model predictive control strategy on a Simulink model. The controller is represented by a subsytem which has for inputs the relevant state variables (x) and the control trajectory (u') calculated in the previous time step, and for outputs the new control trajectory (u) calculated for the current time step. Simplified version in the picture:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/359371/image.png)
This results in a computacionally taxing subsystem which I only want to run once per time step. Simulink chooses ode3 for my model, which is what I've been using before adding the control system. Using this solver, however, means I will have the controller subsystem unnecessarily run 3 times per time step (once per evaluation).
I would wish to know how to make it so that the controller subsystem only runs once per step regardless of the solver. Ideally it should only run on the first evaluation and directly use the output obtained one for the remaining evaluations (or ignore it, since the output control is only applied in the next time step).
Thank you,
José
0 Comments
Accepted Answer
Mrunmayee Gaikwad
on 8 Oct 2020
Hi,
You can set the sample time of a block to [0, 1], it then becomes fixed-in-minor-step. For this setting, Simulink does not execute the block at the minor time steps; updates occur only at the major time steps.
For more information see: https://www.mathworks.com/help/simulink/ug/types-of-sample-time.html
0 Comments
More Answers (0)
See Also
Categories
Find more on Subsystems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!