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

1 回表示 (過去 30 日間)
test test
test test 2018 年 9 月 27 日
コメント済み: test test 2018 年 9 月 27 日
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

採用された回答

Adam
Adam 2018 年 9 月 27 日
編集済み: Adam 2018 年 9 月 27 日
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 件のコメント
test test
test test 2018 年 9 月 27 日
yes, i prefer the method where get one of the values from the radio buttons, thanks alot :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by