作者tnek (kent)
看板MATLAB
标题[问题]两个GUI传递资料
时间Fri Jul 11 15:34:28 2014
大家好
我设计了两个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'.
可以请教是哪里出错了吗??
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.112.4.211
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/MATLAB/M.1405064070.A.084.html
1F:→ aada:试试看加个global cursor.data 07/11 19:23
2F:→ aada:在setappdata(...)下 07/11 19:23
3F:推 yiheng0410:可以把资料存在root下 data = setappdata(0,'data'); 07/11 22:42
4F:→ yiheng0410:再用 getappdata 抓出来 07/11 22:42