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
0 个评论
回答(1 个)
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Raspberry Pi Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!