Clear Filters
Clear Filters

No Simulation Output when Simulations runs from a MATLAB script

25 views (last 30 days)
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 Comment
Christian on 21 Jul 2023
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.

Sign in to comment.

Answers (2)

Andreas Goser
Andreas Goser on 2 Jun 2023
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 on 7 Sep 2023
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');




Community Treasure Hunt

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

Start Hunting!