How to set value of Simulink Rocker Switch from Matlab

3 ビュー (過去 30 日間)
Lila Lotus
Lila Lotus 2020 年 8 月 26 日
編集済み: Fangjun Jiang 2020 年 8 月 26 日
Dear all,
how would I set from Matlab a value of Rocker Switch in simulink.
Given:
Switch "MySwitch" with Labels Sommer=0 and Winter=1
Both variants produce the error below
  1. set_param('mymodel/MySwitch','Value','Sommer')
  2. set_param('mymodel/MySwitch','Value','0')
MWDashboardBlock block (mask) does not have a parameter
named 'Value'
What is the proper way to set value of this block from Matlab
MyGoal:
Set value of the switch
Start simulation
Start simulation is ok, by all my tries to set value of the switch fail.
Thank you

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 8 月 26 日
編集済み: Fangjun Jiang 2020 年 8 月 26 日
This is a Simulink Dashboard block. It needs to be "binding" with another block.
Add a Constant block of value "1". Bound the Rocker Switch block with the Constant block. Then you will see:
When you click the Rocker Switch block, the Constant value changes
When you change the value of the Constant block, the Rocker Switch block switches.
So to change it using Command, you need to run set_param('ConstantBlock','Value','1')

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by