No Simulation Output when Simulations runs from a MATLAB script
9 vues (au cours des 30 derniers jours)
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.
Andreas Goser le 2 Juin 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 le 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');