Radio button option group adding space to end of string property

1 回表示 (過去 30 日間)
CAM
CAM 2016 年 4 月 11 日
When I use findobj to search for a radio button in an option group based on each button's String property, I keep getting empty sets.
h = findobj(handle.optionGroup, 'String', strVariable);
I have discovered that a space character is being added to the end of the String of the buttons, so findobj never can match it to my variable. I have manuallly checked the property window multiple times for each button, and there are no extra spaces at the end of their strings.
Why does this happen?

採用された回答

CAM
CAM 2016 年 4 月 11 日
Thank you for the quick reply, Walter. I will consider your cell-array tip in the future for a more robust GUI.
Just before your email arrived, I solved it. I went to the zoom box for the String property of each radio button, highlighted from the "bottom" to the last 2 characters of the entered string, hit delete, then retyped the last 2 characters. I guess some kind of hidden character (line feed?) was added to the end of the strings, so my odd method removed it.
Thanks again for your time.
  1 件のコメント
Elizabeth Valentin
Elizabeth Valentin 2016 年 5 月 9 日
Hello, I have the same problem. The string has more spaces at the end of it. I am building the user interface via guide. Where can I find the zoom box? Thanks! :)

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 4 月 11 日
Another possibility is that the handle visibility might be set to callback or off . You would need to use findall() instead of findobj() for those.
Are you setting the String property to a cell array of strings, or are you setting it to a string? If you are setting it to a string, does it include any "|" (or bar) characters? Safest is to set it to a cell array of strings.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by