我一直在使用setappdata/getappdata方法來處理這類事情。以下是你所做的一般分類。當您創建的人物給他們這樣的標籤:
figure(..., 'Tag', 'info_gui', ...); % tag name is up to you
figure(..., 'Tag', 'other_gui', ...); % tag name is up to you
任何時候你需要手柄一個或另一個數字只需打個電話給findobj這樣
info_gui_handle = findobj('tag','info_gui');
other_gui_handle = findobj('tag','other_gui');
好了,現在讓存儲一些在info_gui示例數據,我們將更新後
info_gui_data.x = 1;
info_gui_data.y = 1;
setappdata(info_gui_handle, 'info_gui_data', info_gui_data);
一旦你有你的人物設置,你可以做這樣的事情:
% First you get a handle to the info gui figure
info_gui_handle = findobj('tag','info_gui');
% Next you get the appdata thats stored in this figure. In this example
% I have previously stored a struct variable called
% 'info_gui_data' inside the appdata of the info_gui
info_gui_data = getappdata(info_gui_handle ,'info_gui_data');
% Make your changes whatever they are. Here I am modifying variables x
% and y that are stored in the struct info_gui_data
info_gui_data.x = 2;
info_gui_data.y = 2;
% Now that I've made changes to the local variable info_gui_data I can
% now store it back into the info gui's appdata.
setappdata(info_gui_handle ,'info_gui_data',info_gui_data);
我喜歡將我的所有圖形appdata存儲在一個巨型結構中。似乎更容易跟蹤,但它取決於你。希望這有助於:)