How to run two Simulink models at different rates, in the same workspace?

조회 수: 21 (최근 30일)
John 2024년 2월 24일
답변: Raghava S N 2024년 3월 11일
Is it possible to run two Simulink models at different rates, in the same workspace?
I'm looking to run two identical models (of a feedback loop, so same gains, same plant) in the same Simulink workspace, but with one of them (Modeled Sys) running at a faster sim speed, so that it is staying ahead of the other one (Physical Sys).
1) I'm trying to represent having a faster simulated Modeled Sys execution on an embedded controller, running faster than the physical system is, so that the outputs of the Modeled Sys can predict what Physical Sys states will be, and can be used to offer corrections to Physical Sys, before Physical Sys has the time to evolve to those states.
This block diagram is just a mockup to represent what i mean, so no deeper meaning behind what each Sys block is.
In this example, I'm ultimately looking to run multiple Modeled Sys in parallel, and choose the optimal one (coursely analogous to a MPC) to use for correcting Physical Sys. I'm intentionally choosing to not use an official MPC controller.
2) Perhaps there's a way to do this sequentially instead, using some kind of Triggered Subsystem, where that subsystem executes portions of Modeled Sys faster than Physical Sys, since Physical Sys is running according in the main simulation time?
It would also work to have Modeled Sys run extremely quickly every period T of the main sim clock, and simulating only running the upcoming T interval -- but taking time << T .
Ie, at each low-rate tick with period T, Modeled Sys very quickly simulates the entire next T period, and Physical Sys maybe hasn't even started yet (maybe Physical Sys is paused and held back by some trigger, until Modeled Sys finishes).
Or maybe Physical Sys runs continually, but Modeled Sys runs its next T interval so fast on each n*T trigger, that only a small portion of Physical Sys elapses before Modeled Sys finishes its full T-period simulation, and so Modeled Sys's prediction of where Physical Sys is, is available early enough.
But, I'm not sure what Simulink tools can be used for that either.
I'd do this in matlab via sequential execution (where simulation time has no meaning), but Matlab doesn't support mixed-rate modeling, or nonlinearities the same way Simulink does...

답변 (1개)

Raghava S N
Raghava S N 2024년 3월 11일
Hi John,
I understand that you want to run “Modeled sys” at a faster rate than “Physical sys” from the description of the post. This can be accomplished by modifying their sample times so that “Modeled sys” is updated more frequently than “Physical sys”.
The Simulink model is updated as per the model step size. However, the outputs of each block/subsystem are only updated at their corresponding sample times. So, in this case, set “Modeled sys” to have a smaller sample time than “Physical sys” so that it is sampled more frequently, and its outputs are updated before those of the “Physical sys” model.
Please refer to the following links below for more information about how sample time affects Simulink models–


Help CenterFile Exchange에서 Linear Plant Specification에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by