MATLAB: Did I get the same value from radio button in a buttongroup

gui

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

Best Answer

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)