- Drag a "Slider Switch block" to a blank model.
- Connect it to a new "Constant block", so it takes input from the "Slider Switch block". At this point the value of the "Constant block" would be either 0 or 1 depending upon the slider stater ("off" or "on" respectively)
- Then, add a "Switch block" to the model, and connect the earlier created "Constant Block" to the second port of the switch block. Open the "Block Parameters" and change the "Criteria for passing the first input" parameter to "u2~=0".
- Connect the first input port of the "Switch Block" to constant value 1 and the third port to constant value 5.
- Connect the output of the "Switch Block" to the "To Workspace" block. Double click on the "To Workspace Block". Change the Variable name to "res".Now, you should be able to write the output of the "Switch Block" into a workspace variable.
- Now add a new "Resistor Block" to your model. Double click on the block. Set the value of the "Parameter">"Resistance" to "out.res.signals.values(1,1)", and "Save Format" to "Structure".This will read the resistance value from the workspace.
Simulink dashboard switch to control masked parameter
5 views (last 30 days)
Show older comments
I wanted to have a slider switch control such that On position would make it 1 Ohm and off position would make it 5 ohms.
The slider doesn't recognize the resistor as having any controllable parameters. If I go to variables tab and select override for the temperature, the switch would be able to control that alone.
0 Comments
Answers (1)
Ninad
on 3 Nov 2023
Hi Matthew,
You may follow these steps to meet your requirement:
This is what the model will look like:
I have also attached the script for you reference. To test the result. You can try to change the slider states, run the model and check the value of the "out.res.signals.values" variable in the workspace.
Hope this helps.
Regards,
Ninad
0 Comments
See Also
Categories
Find more on Dashboard in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!