[問題]兩個GUI傳遞資料

看板MATLAB作者 (kent)時間10年前 (2014/07/11 15:34), 編輯推噓1(103)
留言4則, 2人參與, 最新討論串1/1
大家好 我設計了兩個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://www.ptt.cc/bbs/MATLAB/M.1405064070.A.084.html

07/11 19:23, , 1F
試試看加個global cursor.data
07/11 19:23, 1F

07/11 19:23, , 2F
在setappdata(...)下
07/11 19:23, 2F

07/11 22:42, , 3F
可以把資料存在root下 data = setappdata(0,'data');
07/11 22:42, 3F

07/11 22:42, , 4F
再用 getappdata 抓出來
07/11 22:42, 4F
文章代碼(AID): #1JlvE624 (MATLAB)