No Simulation Output when Simulations runs from a MATLAB script

조회 수: 23 (최근 30일)
Thomas Fischer
Thomas Fischer 2023년 6월 2일
답변: Simon 2023년 9월 7일
Hi everyone,
I am currently running a Simulink simulation that encounters difficulties in solving certain states, resulting in errors. In order to address this issue, I would like to examine some data prior to the occurrence of the error and remove specific input parameters to allow the simulation to complete without errors. This should happen automatically by running MATLAB script. However, when I run my script and the simulation encounters an error, the simulation does not finish and I do not obtain any simulation output in my workspace. This output is crucial for me to modify the input data.
Interestingly, when I run the simulation directly from Simulink, the output data appears in the workspace as expected even with the error present. My challenge is to find a way to retrieve the simulation output data into my workspace from the MATLAB script, even if the simulation does not finish.
I would greatly appreciate any insights or suggestions on how to overcome this issue.
  댓글 수: 1
Christian
Christian 2023년 7월 21일
I have the exact same issue and I am looking for a solution. sim does not behave like clicking on the run button. The run button always produces output. sim only produces output when the simulation finishes.

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

답변 (2개)

Andreas Goser
Andreas Goser 2023년 6월 2일
My first thought is about the fundamental issue with your simulation. Assuming you have a somewhat recent release, there a many ways to debug your simulation. I mainly think about the "Step forward" functionality and you can simply select a signal to see the value.
About the behaviour running the simulation from a script: Please verify if it is not a function. If it is a function, all variables are in the function workspace, not the base workspace.

Simon
Simon 2023년 9월 7일
Had the same issue.
Called the Simulation with sim(modelname, 'StopTime','SimuTime');
Found the Output data in the var ans instead of the var out.
If you need it a specific name for the out put simply call
testout = sim(modelname, 'StopTime','SimuTime');

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by