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 comentarios

Ameer Hamza
Ameer Hamza el 10 de Abr. de 2020
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?
Adam Chapman
Adam Chapman el 10 de Abr. de 2020
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"

Iniciar sesión para comentar.

 Respuesta aceptada

Adam Chapman
Adam Chapman el 10 de Abr. de 2020

0 votos

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 comentario

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?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 10 de Abr. de 2020

Comentada:

el 6 de En. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by