How to connect several Simulink blocks to one Simulink Dashboard toggle switch ?

6 ビュー (過去 30 日間)
Hadrien Passet
Hadrien Passet 2023 年 4 月 19 日
回答済み: Govind KM 2024 年 9 月 26 日
Dear MathWorks community,
I would like to chnage the value of sereval "constant" simulink blocks by using a single toggle switch from the Dashboard library.
However when I try to connect them, it looks like we are allowed to connect only one block.
Is there any solution to do it ?
Many thanks in advance for your support.
Hadrien

回答 (1 件)

Govind KM
Govind KM 2024 年 9 月 26 日
Hi Hadrien,
I was facing a similiar issue. As a workaround, the "Callback Button" from the "Simulink/Dashboard" library can be used to achieve the same effect as a "Toggle Switch" for multiple blocks at once. Here is sample code for the "ClickFcn" callback which checks the current value of "Constant" blocks in the model and toggles values when clicked:
if(get_param('myModel/Constant1','Value')=='10') %Taking random values to be toggled
set_param('myModel/Constant1','Value','2')
set_param('myModel/Constant2','Value','3')
else
set_param('myModel/Constant1','Value','10')
set_param('myModel/Constant2','Value','15')
end
A sample model has been attached for your reference.
Hope this helps!

カテゴリ

Help Center および File ExchangeRaspberry Pi Hardware についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by