Problem to pause and resume Simulink simulation.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hi guys! I have a trouble with simulink. I want to run a simulation and after some time it pauses, runs a script to calculate some values, updates these as new parameters of Simulink blocks and then resume the simulation. This process must be done several times. Reading in the page https://it.mathworks.com/help/simulink/ug/controlling-execution-of-a-simulation.html i am able to create a pause using assertion block. In the field "Simulation callback when assertion fails" of this block i put the code: * set_param(bdroot,'SimulationCommand','pause'); * run('myscript.m'); * set_param(bdroot,'SimulationCommand','continue'); so when the pause time is reached this block pauses the simulation, launches myscript.m but doesn't resume the simulation after the last command. It is very strange because if I use set_param function with 'SimulationCommand' options 'start', 'pause' or 'stop' it works fine. Only the 'continue' option isn't "accepted". So i tried to change the code to include set_param functions in myscript.m but nothing has changed. Another doubt regarding the command set_param(bdroot,'SimulationCommand','continue') is that if this is launched from command window works correctly. So given that the syntax is correct, I can't understand why the simulation doesn't resume again. Some idea? Thanks for the attention, Fabio
1 commentaire
ganeshan viswanathan
le 11 Sep 2017
Modifié(e) : ganeshan viswanathan
le 11 Sep 2017
set_param('model name','StopTime','time_delay10') sim modelname "Do the calculations here" set_param('model name','SimulationCommand','update') "create the delay time according to when you need to stop it"
Réponses (2)
ES
le 23 Mar 2017
1. Any chance your script changes bdroot?
2. Also, do you remember to update the value of the constant block after the assertion failure?
3. Once you have updated workspace with values, be sure to update the model because the workspace values are updated to the model only on Model update
set_param(bdroot, 'SimulationCommand', 'update')
2 commentaires
X W
le 6 Août 2017
Hi Fabio, I am trying to address this same issue, any updates on how(if) you were able to get this resolved? Or did you try some other way?
ganeshan viswanathan
le 11 Sep 2017
set_param('model name','StopTime','time_delay10') sim modelname "Do the calculations here" set_param('model name','SimulationCommand','update') "create the delay time according to when you need to stop it"
0 commentaires
Voir également
Catégories
En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!