Why did I get the same value from radio button in a buttongroup?
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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)
More Answers (0)
See Also
Categories
Find more on Contour Plots 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!