フィルターのクリア

How to share variables across GUIs?

2 ビュー (過去 30 日間)
Lisa Wu
Lisa Wu 2012 年 11 月 21 日
As it said in title,there is a variant Num1 in GUI1, I hope that in GUI2 Num1 can changged, how ? Thank you!
  2 件のコメント
Jan
Jan 2012 年 11 月 21 日
What does "variant Num1 in GUI1" exactly mean? Is this the tag of an uicontrol, a variable in the application data set by guidata() or a field in a struct stored in the UserData?
Lisa Wu
Lisa Wu 2012 年 11 月 21 日
In GUI1:
function edit1_callback()
num1 = get(hObject,'string');
handles.num1=num1;
guidata(gcbo,handles);
In GUI2,how can i use handles.num1 ? Thank you!

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

採用された回答

Arthur
Arthur 2012 年 11 月 21 日
I prefer to store and share data with the function setappdata and getappdata. This is, in my opinion, more clear and better structured.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 11 月 21 日
If you used GUIDE, you need to use guidata() on the figure number for GUI2 in order to get GUI2's handle structure in GUI1. Then you can change things in the normal way. For example,
handles2 = guidata(GUI2_figure);
set(handles2.Num1, 'Value', get(handles.Num1, 'Value'))
  1 件のコメント
Lisa Wu
Lisa Wu 2012 年 11 月 21 日
When I put the aboves commands in pushbutton1 of GUI1, error:【Erroring using get; Convertion to duoble from cell is impossible.】
So where to put above command? Thank you very much!

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

カテゴリ

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