필터 지우기
필터 지우기

Simulink Run and Command Window sim(); differences

조회 수: 9 (최근 30일)
Matteo Bordignon
Matteo Bordignon 2023년 2월 12일
댓글: Paul 2023년 9월 22일
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
Chao Luo
Chao Luo 2023년 2월 15일
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 2023년 2월 16일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Raghav
Raghav 2023년 4월 7일
편집: Raghav 2023년 9월 22일
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
Chris
Chris 2023년 9월 21일
Can you explain how to check the settings of the Simulink simulation engine vs the MATLAB simulation engine?
Paul
Paul 2023년 9월 22일
More generally, what is the distinction between the "Simulink simulation engine" and the "MATLAB simulation engine." Is there a doc page the explains this?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulation에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by