Pausing Simulink Model programmatically not working

3 次查看(过去 30 天)
I'm trying to pause my simulation using this line of code:
set_param(app.model,'SimulationCommand','pause')
However for some reason the simulation just continutes to run, effectively ignoring this. I know this line of code is definitely called but it doesn't work.
I'd like to have a system where I can pause and continute the simulation whenever I want as the stop time is 'Inf' with certain conditions to stop it if needed.
Any reason why I cannot pause the simulation?

回答(1 个)

Kshittiz
Kshittiz 2023-9-21
Hi Byron,
I understand you’re using the “set_param” function to pause your simulation but it’s not working as per your expectation.
Since I do not have your entire script, it is difficult to determine the exact reason why the "set_param" function is not functioning as expected. However, as a possible workaround for this issue, you can incorporate the "pause" command within your simulation loop or callback.
The “pause” command temporarily stops MATLAB execution and waits for the user to press any key. Note that although it temporarily stops the execution of Simulink models, it does not pause their repainting. To learn how to use it, refer the following documentation:
I hope this solves your query.
Thanks and Regards,
Kshittiz

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by