Simulation status is stopped but I cannot start new simulation from script because Matlab assumes it is still running

9 visualizaciones (últimos 30 días)
Hi,
I have a problem with running a Simulink model from script many times in a row. While running a simulation I check in a timer update function with get_param(SimName, 'SimulationStatus'), if the model's status is 'stopped' or not, and if it is 'stopped' I save the output data, change some variables, and try to run the simulation again with set_param(SimName, 'SimulationCommand', 'start'). This mostly works fine but sometimes (it seems quite stochastic, so I really do not know what could cause it) I catch the following error: 'Cannot start a new command line simulation while a simulation has started for the same model.'
Could anyone please tell me what the source of the problem is and if there is any solution for it. Thank you in advance.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 13 de Jul. de 2023
Might it be too fast to re-start the simulation? There could be some post-simulation processing going on.
Anyway, in the M-script, add a pause(3) statement before re-starting the simulation to see if it improves.

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by