How to programatically send Update Diagram command to Simulink

44 ビュー (過去 30 日間)
Paulo Silva
Paulo Silva 2011 年 7 月 15 日
コメント済み: Jyoti Sachdeva 2023 年 10 月 29 日
I stumble upon a problem in my project, there's one GUI that controls the simulation and that GUI changes variables on MATLAB workspace, the same variables are used in the simulation but simulink doesn't read the new values unless the simulation stops and starts or the Update Diagram command is issued, so the question is how to force simulink to Update Diagram in my code?
Already tried:
eval([SimFileName '([],[],[],''update'')' ]);
but it doesn't do what I want.
Meanwhile I found one solution but it's using QuaRC MATLAB Functions, would be better to have something withing simulink functions.
qc_update_model
Any help is welcome, thanks
  3 件のコメント
Paulo Silva
Paulo Silva 2011 年 7 月 15 日
No, the GUI just changes values of the variables on the workspace and the simulation files and other tools (to calculate performance parameters) use those variables.
Vinol Joy D'souza
Vinol Joy D'souza 2011 年 7 月 19 日
I want to change the parameters of a block when the model is running and simultaneously see the changes in the output.
For eg.I have a sine block connected to a Scope.and when i start the simulation.I want to change the frequency of the sine wave and see the corresponding frequency changed wave on the scope output.I want to do this as i want to see how my model behaves for different frequencies...HOw do i do this???

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

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 7 月 15 日
Use set_param('sys', 'SimulationCommand', 'cmd')?
where 'sys' is the name of the system and 'cmd' is 'start', 'stop', 'pause', 'continue', 'update', or 'WriteDataLogs'
  3 件のコメント
Vinol Joy D'souza
Vinol Joy D'souza 2011 年 7 月 19 日
I want to change the parameters of a block when the model is running and simultaneously see the changes in the output.
For eg.I have a sine block connected to a Scope.and when i start the simulation.I want to change the frequency of the sine wave and see the corresponding frequency changed wave on the scope output.I want to do this as i want to see how my model behaves for different frequencies...HOw do i do this???
dc
dc 2023 年 6 月 6 日
移動済み: Fangjun Jiang 2023 年 6 月 13 日
that's what i need,thanks

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

その他の回答 (2 件)

Noam Greenboim
Noam Greenboim 2017 年 7 月 11 日
set_param(bdroot,'SimulationCommand','Update')
  2 件のコメント
João
João 2023 年 3 月 22 日
This worked for me. Thanks!
Jyoti Sachdeva
Jyoti Sachdeva 2023 年 10 月 29 日
Instead of using bdroot,
mdlName = MotorCtrl.slx
set_param(mdlName,'SimulationCommand','Update')
This command is equivalent to programatically running Ctrl+D on MotorCtrl.slx model.

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


Rick Rosson
Rick Rosson 2011 年 7 月 15 日
Hi Paulo,
Although not ideal, the following line of code should work:
Simulink.BlockDiagram.getSampleTimes(SimFileName);
Make sure that the value of SimFileName excludes the .mdl extension, and that the file is already open at the time of the call.
HTH.
Rick
  1 件のコメント
Paulo Silva
Paulo Silva 2011 年 7 月 15 日
Thanks Rick, I tested that code but it didn't work, thank you anyway for trying :)

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

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by