MATLAB Answers

Simulink: How to run a subsystem only once per time step regardless of solver?

10 views (last 30 days)
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:
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é

Accepted Answer

Mrunmayee Gaikwad
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.

More Answers (0)

Categories

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!