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"

댓글을 달려면 로그인하십시오.

 채택된 답변

Adam Chapman
Adam Chapman 2020년 4월 10일

0 개 추천

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에 대해 자세히 알아보기

질문:

2020년 4월 10일

댓글:

2022년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by