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

4 views (last 30 days)
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

Accepted Answer

Adam
Adam on 27 Sep 2018
Edited: Adam on 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 Comment
test test
test test on 27 Sep 2018
yes, i prefer the method where get one of the values from the radio buttons, thanks alot :)

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!