Why can't I continue my simulation using 'PauseFcn' callback?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 4 de Abr. de 2019
Editada: MathWorks Support Team
el 29 de Ag. de 2024
I am pausing my simulation using an assertion block, as shown in below documentation example:
Please run the below command in the command window of installed MATLAB R2019a version to get release specific documentation
>> web(fullfile(docroot, 'simulink/ug/controlling-execution-of-a-simulation.html'))
I tried to add below simulation command to the 'PauseFcn' callback to resume the simulation automatically, but it doesn't work:
set_param(bdroot,'SimulationCommand','continue')
However, I can continue the simulation if I enter the command manually at the MATLAB Command Prompt. Why is this?
Please follow the below link to search for the required information regarding the current release:
Respuesta aceptada
MathWorks Support Team
el 29 de Jul. de 2024
Editada: MathWorks Support Team
el 29 de Ag. de 2024
Since MATLAB Release 2016a, it is not possible the continue a simulation using 'PauseFcn' callback anymore.
We disallowed calling "set_param(gcs,'SimulationCommand','continue')" from the 'PauseFcn' callback, as this is the kind of thing that can easily end up in an infinite recursion if not done properly.
There is currently no workaround to achieve the old behavior; so the best way to move things forward would be to look into other alternate workflows that would be more robust to achieve what you really need.
For example, if you perform co-simulation, an S-Function could do something similar to what the 'PauseFcn' callback is doing. You would not need to pause, the S-Function would call the external environment, wait for it to do its thing and when it is done, it would keep moving forward. That would be a lot more robust and would probably be faster too.
If it is absolutely necessary to retain this workflow, please consider the following workaround in the "PauseFcn" callback:
xx = timer('ExecutionMode','singleShot','StartDelay',0.1,'TimerFcn','set_param(bdroot, ''SimulationCommand'', ''continue'')');
start(xx)
In summary, one creates a timer object and attaches the "continue" function, and then start the timer which will then continue the simulation after the "PauseFcn" callback is exited.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Function Creation 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!