How do I pass value of State Button in app designer into a Simulink model?
3 views (last 30 days)
Show older comments
I have created and linked a simple app using app designer that has just one State Button and a basic simulink model that has a switch block. I'd like to use the value of the state button (0 or 1) as the second input to the switch block, so the logic through the switch block changes when the state button is pressed/released. How do I do this? Usually connections are made using bindings, but for a state button app designer states 'bindings not supported'. I'm thinking there must be a way around this maybe using a callback - so that when the button is pressed the callback sets the value of a Variable in the model workspace that is picked up by an input into the switch state etc.. but I've had a go and can't see how to do this.
2 Comments
Amish
on 25 Mar 2025
You can define a variable in the Model Workspace that is connected to the control input of the switch block. This variable can then be modified using a Callback function for the State button in the app using the assignin and set_param function to update the variable.
Answers (0)
See Also
Categories
Find more on Simulink Environment Customization 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!