About controlling Simulink model execution at run time

조회 수: 1 (최근 30일)
Luca Barbiero
Luca Barbiero 2013년 7월 12일
I would like to run a Simulink model from a MATLAB script. Is there a way to eventually stop and restart the simulation, depending on a particular signal value in the model?
In particular, my application is a transmission chain. Since I don't know in advance the proper noise level to set, I'd like to run the model with an initial one, and then eventually stopping, changing the parameter, and restarting, depending on the Error Rate Calcutation, which indeed is a signal in the model.
I've read about accessing blocks data at run time in the documentation, but still I didn't understand if I can do what I want.
Thanks for any help, Luca

채택된 답변

Kaustubha Govind
Kaustubha Govind 2013년 7월 12일
You might want to use the Stop block to build the stop logic into the model itself. You can then run the model using the SIM command in a loop from MATLAB, and restart simulation at each iteration after modifying the required parameters. Note that the SIM command will not return until the model stops running completely (a pause will not do).

추가 답변 (1개)

David Sanchez
David Sanchez 2013년 7월 12일
You can use the following commands to control the simulink model:
set_param(gcs,'SimulationCommand','Pause');
set_param(gcs,'SimulationCommand','Continue');
set_param(gcs,'SimulationCommand','Stop');
  댓글 수: 1
Luca Barbiero
Luca Barbiero 2013년 7월 12일
Thanks for your answer. But do you know if I can have the script executing those commands conditioned on a certain signal in the model?
In other words: can a script get the actual value of a signal in a model, while the latter is running, and depending on that, eventually stopping automatically the simulation by
set_param(gcs,'SimulationCommand','Stop');
This is what I'm really wondering! Maybe it's easier to do this from inside the model itself?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by