Model reference speed problem (slow)

Hello everybody,
I am trying to convert an atomic subsystem which contains other atomic subsystems with different time steps into a model reference, see the first image.
Principal.PNG
However, when I convert directly the main atomic subsystem, the simulation runs very slow.
ModelReference1.PNG
I have realized that if I remove all the output ports, the simulation runs as fast as without model reference.
ModelReference2.PNG
I do not know why it is happening. Could someone help me with this problem, please? This model in the future will be connected with other models, so the output ports are necessaries.
Thanks in advance!

 Risposta accettata

Fangjun Jiang
Fangjun Jiang il 31 Gen 2019

0 voti

My guess is that it is not equal comparison. In your first picture, all the outputs are terminated. Maybe Simulink did some optimization not to calculate those outputs. When it is converted to model reference, it is different. All those outputs need to be calculated even though outside the model reference, they are still terminated.
In your first picture, connect all the outputs of the automic subsystem to Outport blcoks and then see if there is a speed difference.

2 Commenti

Thanks for your answer Fangjun Jiang. You are right. I have connected all the outputs of the atomic subsystem to output ports and the speed goes down.
Do you know any possible solution for this issue? I need to protect this subsystem and the output ports must be used for connecting signals with other blocks without increasing the simulation time.
Thanks!
If that is the case, I guess there is no issue. Your first case is faster because it is not reflecting real usage (no outputs). Pre-compiled model reference is already faster than regular subsystem. Sometimes it takes time to run the simulation. Your next option is to improve your algorithm or do "Analysis", "Performance Tools".

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by