Filter löschen
Filter löschen

Simulink Run and Command Window sim(); differences

9 Ansichten (letzte 30 Tage)
Matteo Bordignon
Matteo Bordignon am 12 Feb. 2023
Kommentiert: Paul am 22 Sep. 2023
I developed a model of my system in Simulink; it should run and display an animation, depicting the evolution of the system.
I am noticing differences in the behivour of the simulation when pressing on the "Run" button in Simulink and using the sim("mymodel.slx") in Matlab; the main difference is the usage of the dedicated GPU (active while the command is run in Matlab, not active when the simulation is started directly on Simulink), resulting in a very laggy animation. Moreover, there where also problems in displaying the figure of the animation when running with the Run button in Simulink.
To solve this problem I tried to use the GPU Coder package with, unfortunately, very poor results: the time to compile the model grew a lot (few seconds to minutes) and using the Windows Task Manager i could still see the dedicated GPU still off, resulting again in a poor quality of the animation. I don't think this package is needed since everything was running smoothly without it when the simulation was run from the Matlab Command Line.
Why is this happening? Shouldn't in theory the 2 option provide the same result? Does someone have a solution for this? Running every time from Matlab is limiting (for example i cannot Pause the execution, but only Stop it with Ctrl+C) and annoying.
  2 Kommentare
Chao Luo
Chao Luo am 15 Feb. 2023
With GPU Coder it would compile the model in a way that tries to parallelize simulation. But it may not be able to parallelize depending on how the model is implemented. It takes longer time to compile is expected. Based on your obeservation, it seems no computation is parallelized on GPU.
It looks to me the problem is running MATLAB, it uses GPU to show the animation, but not when it is running from Simulink. Currently, GPU Coder would not change the way how animination is displayed.
Matteo Bordignon
Matteo Bordignon am 16 Feb. 2023
Thank you for the GPU Coder clarification.
The problem is exacly the one you mentioned. Is there a way to make Simulink use the GPU for the animation? I tried looking in Windows Graphics Settings in order to change Simulink to 'High Performance' since it helped with MATLAB scripts but i cannot find the app. I guess it's because Simulink is not a separeted app with respect to matlab.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Raghav
Raghav am 7 Apr. 2023
Bearbeitet: Raghav am 22 Sep. 2023
Hi,
Based on your question, I understand that you are facing difference in model simulation while executing through Simulink and command window.
There could be several reasons why you are observing differences in the behavior of your Simulink model when running it using the "Run" button in Simulink versus the "sim" command in MATLAB. One possible reason could be related to the configuration of your Simulink model or the settings of your MATLAB environment.
When you run the simulation using the "Run" button in Simulink, Simulink uses its own simulation engine to run the simulation, which may have different settings and configurations than the MATLAB environment you are using to run the "sim" command. This can result in different performance and behavior of the simulation.
On the other hand, when you run the simulation using the "sim" command in MATLAB, you are directly invoking the MATLAB simulation engine, which may have different settings and configurations compared to the Simulink simulation engine.
Regarding the usage of the dedicated GPU, it is possible that the Simulink simulation engine is not configured to use the GPU, while the MATLAB simulation engine is. This can lead to the observed differences in performance and behavior.
To resolve this issue, you may want to check the settings and configuration of your Simulink model and the MATLAB environment to ensure that they are consistent. You can also try to configure the Simulink simulation engine to use the GPU if possible.
Overall, it is difficult to provide a specific solution without more information about your Simulink model and the MATLAB environment you are using.
Thanks,
Raghav Bansal
  2 Kommentare
Chris
Chris am 21 Sep. 2023
Can you explain how to check the settings of the Simulink simulation engine vs the MATLAB simulation engine?
Paul
Paul am 22 Sep. 2023
More generally, what is the distinction between the "Simulink simulation engine" and the "MATLAB simulation engine." Is there a doc page the explains this?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulation finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by