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

12 vues (au cours des 30 derniers jours)
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.

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 13 Juil 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.

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by