Programatically change state of slider switch

I am using a slider switch from the Simulink Dashboard library.
Can I change its state to "off" with a Matlab script using set_param?
So far I have been unable to find a relevant parameter with get_param (gcb,'ObjectParameters').
This must be the first Matlab question I've asked in about 4 years. Really stumped on this one :/

2 个评论

But why do you want to change the state of the slider switch Programmatically? This seems like an unnecessary step. Why don't you directly control the variable connected with the slider switch?
The switches are simulating a user interface where pressing the button turns a particular mode on, but those modes can be switched off by the system itself. This is simulating a vehicle HVAC system- pressing the "defrost windshield" button may turn of other non essential modes like "air to feet"

请先登录,再进行评论。

 采纳的回答

Found a solution using set_param and atatched an example simulink model (This one is hard to explain in words but reading the model conveys teh concept more clearly). My attempt at a concise solution follows..
The simulink dashboard objects reference the value a signal somewhere in your simulink model.
My dashboard switch is referencing the value in a "constant" block which represents an on/off switch for the system.
I then have an output from my system describing the on/off state. If a falling edge is detected on that signal, we can detect that the system has turned itself off.
It is then possible to use a triggered subsystem with Matlab function block in it to call the set_param function. That function can set the value of the constant block which the dashboard switch is referencing.
I have attached an example system that turns itself off after it has been on for three seconds and deactivates the on/off switch.

1 个评论

I don't have StateFlow so I can't peek inside some of your elements.
What is the name of the param you set to adjust the slider switch state?

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Control Simulations with Interactive Dashboards 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by