Problem to pause and resume Simulink simulation.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
ganeshan viswanathan
el 11 de Sept. de 2017
Editada: ganeshan viswanathan
el 11 de Sept. de 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"
Respuestas (2)
ES
el 23 de Mzo. de 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 comentarios
X W
el 6 de Ag. de 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
el 11 de Sept. de 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 comentarios
Ver también
Categorías
Más información sobre Programmatic Model Editing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!