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

6 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Raspberry Pi Hardware 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by