Pausing Simulink Model programmatically not working

3 views (last 30 days)
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?

Answers (1)

Kshittiz
Kshittiz on 21 Sep 2023
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

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!