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

6 visualizaciones (últimos 30 días)
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

Respuestas (1)

Govind KM
Govind KM el 26 de Sept. de 2024
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!

Categorías

Más información sobre Raspberry Pi Hardware en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by