How can I control the simulation run time from m.file?

1 回表示 (過去 30 日間)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA 2022 年 4 月 8 日
回答済み: Esha Chakraborty 2022 年 4 月 12 日
I have both the smulation file and the m.file. I need to run the simulink based on values from the m.file. But I also need to control the run time of the simulink. And the control needs to be done from the m.file. Is there any command to control the simulink run time from m.file? If so, What would be th syntex of it?
  3 件のコメント
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA 2022 年 4 月 11 日
Yes
Paul
Paul 2022 年 4 月 11 日
Are you running the simulation from the .m file or command line using the sim() command? Or are you running the simulation by clicking the play button?

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

採用された回答

Esha Chakraborty
Esha Chakraborty 2022 年 4 月 12 日
Hi Ananta,
I understand that you want to control the simulation stop time programatically.
You can use the sim command to specify the StartTime and StopTime of the Simulink model programatically from the command line as given in the code below:
sim('modelName','StartTime','0','StopTime','10','FixedStep','0.2')
You can get further insights on the sim command here.
In case of an interactive simulation, you can also use the set_param command with multiple pairs of ParamaterName, Value arguments and StopTime parameter is just one of them.
set_param('modelname', 'StopTime', '3000')
More examples on set_param can be found here.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by