"No public property string exists for class matlab.ui.​control.UI​Control."

7 ビュー (過去 30 日間)
Penny
Penny 2018 年 4 月 6 日
コメント済み: mccoy mcpeter 2023 年 3 月 13 日
I'm trying to create a GUI in GUIDE with radio buttons and having never used radio buttons before and struggling to make any sense of the available help I am trying to just make a very basic placeholder script to confirm that the GUI is recognising my radio buttons.
% --- Executes when selected object is changed in uibuttongroup1.
function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uibuttongroup1
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h = guidata(gcbo);
handles.text21.string = 'boop';
guidata(gcbo, h);
text21 is my field on the GUI I am just using to test output from functions, its working fine with other features such as a listbox. When I do this, I get the error message in the heading, which remarkably gets no results at all on Google.
What I actually want to do is something which meaningfully refers to the selected button rather than just a token output when the selection is changed, how do I do that? Just outputting something associated with it to text21 would do to start with, I could work out the rest from there. This seems like the most basic thing you could possibly do with a radio button and yet I can't find that anywhere.

採用された回答

Matt J
Matt J 2018 年 4 月 6 日
編集済み: Matt J 2018 年 4 月 6 日
Have you tried
set(handles.text21, 'String', 'boop');
  2 件のコメント
Penny
Penny 2018 年 4 月 6 日
That works, thanks!
mccoy mcpeter
mccoy mcpeter 2023 年 3 月 13 日
Thank you. This has helped me in solving a similar problem.

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 4 月 6 日
When using the object.propertyname syntax to set or query property names of a Handle Graphics object object, propertyname must be the full name of the property with the correct case. Text objects do not have a property named string, they have a property named String.
t = text(0.5, 0.5, 'Hello');
pause(2)
t.String = 'Goodbye';
pause(2)
t.string = 'Back again!'; % this will error

カテゴリ

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