- 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
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Ninad
2023-11-3
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dashboard 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!