Why did I get the same value from radio button in a buttongroup?

1 vue (au cours des 30 derniers jours)
test test
test test le 27 Sep 2018
Commenté : test test le 27 Sep 2018
When I click the button OK, it displays same value, while RGB is selected, value is 1, and HSV should be 0, but I can get the same value. I have attached the .m file and .fig file above

Réponse acceptée

Adam
Adam le 27 Sep 2018
Modifié(e) : Adam le 27 Sep 2018
You are always asking for the Selected object's 'Value'. This will always return 1 because it is the selected object.
You should compare SelectedObject against handles.rgb instead, e.g.
method_selection = get(handles.uibuttongroup1,'SelectedObject') == handles.rgb;
or you could just check the RGB button itself for its value e.g.
method_selection = get( handles.rgb, 'Value' )
though this only works if you have only two options so you can interpret it as a boolean. Otherwise you would need a switch statement to compare SelectedObject against each of your buttons (or use the 'Tag' from the SelectedObject, but it still needs a switch statement or if-else block)
  1 commentaire
test test
test test le 27 Sep 2018
yes, i prefer the method where get one of the values from the radio buttons, thanks alot :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by