How can i get the same text from another function

1 回表示 (過去 30 日間)
Mai Le Thai
Mai Le Thai 2018 年 10 月 11 日
コメント済み: Mai Le Thai 2018 年 10 月 11 日
  • How can I get the texts, that i have created in the function handles to the function checkboxValue. I want to delete them in the second function. The two functions are not in the same script? Thanks
function handles = plotCAT(vaargin)
text(data(ObstPedestFlag, 1)- 0.5, data(ObstPedestFlag, 2) + 0.5, cellstr('PED-TP'));
text(data(ObstMovInvFlag, 1)- 0.5, data(ObstMovInvFlag, 2) + 0.5, cellstr('INV-TP'));
text(data(ObstStatFlag, 1)- 0.5, data(ObstStatFlag, 2) + 0.5, cellstr('STAT-TP'));
text(data(ObstMovFlag, 1)- 0.5, data(ObstMovFlag, 2) + 0.5, cellstr('MOV-TP'));
end
function checkboxValue= enter_call(hObject, eventdata, handles)
handles = guidata(hObject);
handles.checkboxValue= cell2mat(get(handles.h_checkbox, 'Value'));
handles.checkboxValue
guidata(hObject,handles);
close(gcf)
end

採用された回答

jonas
jonas 2018 年 10 月 11 日
編集済み: jonas 2018 年 10 月 11 日
Store their handles in a variable and pass it as output from the first function and input to the second. Alternatively you could use findobj in the second function to grab their handles. If you prefer the latter, then I would set a 'tag' on all the objects that you want to delete, so that you can use:
% First function
text(x,y,'mytext','tag','mytag')
% Second function
delete(findobj(groot,'tag','mytag'))
  12 件のコメント
Stephen23
Stephen23 2018 年 10 月 11 日
編集済み: Stephen23 2018 年 10 月 11 日
"I have tried your solution but it showed me an error"
What I wrote was a comment to jonas, it was not a complete answer to your question.
To use it you would still need to pass the variable c from one function to the other. Three hours ago I gave you links that explain how to pass data from one function to another:
Read those links. If you are sensibly writing your own GUI then I recommend using nested functions. If you are unfortunately using GUIDE, then use guidata.
Mai Le Thai
Mai Le Thai 2018 年 10 月 11 日
Oh, thanks Stephan! I missed your message to read. I am going to read the links.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

タグ

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by