Why does Simulink pauses execution on pause command in Matlab-app?

1 次查看(过去 30 天)
I have the problem that Simulink pauses when I call the model in an app (with App Designer) and then use the pause or waitfor command in that app. For this period of time the model continues to run, but the simulation time does not continue.
...
load_system('model');
set_param('model','SimulationCommand','Start');
...
pause(10);
...
Does anyone have any idea how to work around this?

回答(1 个)

Imran
Imran 2023-1-2
Hello Paul,
I understand that when you use the 'pause' command in your app in app designer, model continues to run, but the simulation time stops.
The 'pause' command only causes the MATLAB commands and scripts to pause, not the model simulation.
While MATLAB is paused, the following continue to execute:
  • Repainting of figure windows, Simulink block diagrams, and Java® windows.
  • Call-backs from figure windows.
  • Event handling from Java windows.
The way to pause a simulation is by using the following command
set_param('<modelname>','SimulationCommand','pause')
In your case, as the model’s name is 'model', you should replace the pause command with the following command
set_param('model','SimulationCommand','pause')
I hope this would help.

类别

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

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by