MATLAB Answers

In appdesigner how to select radio button from code?

66 views (last 30 days)
Tamas Muszbek
Tamas Muszbek on 4 Apr 2017
Commented: Ramnath T J on 31 Jul 2019
I want to force a radio button in a button group selected by code.
I tried overwriting the SelectedObject property of the group, or the Value property of the buttons, but in the GUI nothing seems to change. The originally selected button does not behave like selected anymore once I overwritten the properties, but the user sees it as selected and it is confusing.
So how can I set the button in a way that it changes in the GUI display as well?

Answers (1)

Cris LaPierre
Cris LaPierre on 7 Nov 2018
In appDesigner, you can change the value property of the button you want to have selected.
To test, I created a new app and added a Radio Button Group. This adds three radio buttons with names button, button2 and button3. The first radio button is selected by default. I also added a Button with a callback function containing the following code:
app.Button2.Value = 1;
When I press the button, it sets the value of button2 to 1. The Radio Button Group will automatically deselect the first radio button and show the second as selected.
  1 Comment
Ramnath T J
Ramnath T J on 31 Jul 2019
Can i make all radio buttons in a button group to be false(0) in a button group ?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!