[问题]两个GUI传递资料

楼主: tnek (AbiAbi)   2014-07-11 15:34:28
大家好
我设计了两个GUI接口
第一个GUI的Tag为"gui_his"
今天我从gui_his的一个按钮抓资料
资料为"cursor.data"
我希望第二个GUI的按钮可以抓到此资料
因为我想要将这笔资料传递到第二个GUI做运算
我的程式码为
%在gui_his里
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%资料来源我就简略了
setappdata(handles.gui_his,'mydata',cursor.data)
%然后在第二个gui里
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mydata = getappdata(handles.gui_his,'mydata');
但程式出现错误为
Reference to non-existent field 'gui_his'.
可以请教是哪里出错了吗??
谢谢
作者: aada (aada)   2014-07-11 19:23:00
试试看加个global cursor.data在setappdata(...)下
作者: yiheng0410 (暱称)   2014-07-11 22:42:00
可以把资料存在root下 data = setappdata(0,'data');再用 getappdata 抓出来

Links booklink

Contact Us: admin [ a t ] ucptt.com