Stopping and Starting Simulation from GUI

1 回表示 (過去 30 日間)
Mark Ekblad
Mark Ekblad 2017 年 10 月 24 日
コメント済み: Mark Ekblad 2017 年 10 月 28 日
I have a GUI that runs a simulation, when a certain event occurs I would like to stop the simulation and then start a new one with possibly different parameters( e.g. in a loop). When I use set_param(RunInfo.SimulinkModelName, 'SimulationCommand', 'stop'); The simulation does not stop immediately and get_param(bdroot,'SimulationStatus') returns running. When the simulation has stopped it no longer calls my event listener so I have no way to start a new simulation. Basically I want the user to load some files that have different model parameters. They will push a start button and then the program should loop through the sets of parameters, one simulation after another. During the simulation my event listener is taking some action at different time steps. Any ideas?
  2 件のコメント
Arvind Narayanan
Arvind Narayanan 2017 年 10 月 27 日
Have you tried using the stop() command instead of using set_param() to stop simulation? This is the correct way to stop a model simulation. You can then use the run() or continue() commands to continue the simulation from the current breakpoint.
Mark Ekblad
Mark Ekblad 2017 年 10 月 28 日
I am not debugging the model. I am running a simulation and then when a certain value from the output reaches a prespecified value I want to stop and then run a new simulation with different parameter. The stop command will not work unless you use sldebug

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by