Problem to pause and resume Simulink simulation.
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
ganeshan viswanathan
2017-9-11
编辑:ganeshan viswanathan
2017-9-11
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"
回答(2 个)
ES
2017-3-23
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 个评论
X W
2017-8-6
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
2017-9-11
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!