No Simulation Output when Simulations runs from a MATLAB script

18 visualizzazioni (ultimi 30 giorni)
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 Commento
Christian
Christian il 21 Lug 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.

Accedi per commentare.

Risposte (2)

Andreas Goser
Andreas Goser il 2 Giu 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
Simon il 7 Set 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');

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by