[討論] GUI 讀取檔案傳值問題

看板MATLAB作者 (robottt)時間13年前 (2012/05/31 23:04), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/2 (看更多)
各位高手請教一下: 我寫了一組m file 用來抓取檔案並讀取檔案內的數值 之後在將此讀取的數值做運算,並繪圖。 以m-file可以正常執行。 轉為.exe檔後,畫面可讀取,但是近一步按bottom2 卻顯示 Undedined function or variable 'T' 我知道這代表變數 T 沒有傳到 callback 的部份。 但是卻不知道應該從哪個 handle 抓給 哪一個 handle 請大家幫忙解答一下。 感謝 以下為原始碼: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function out=GUI_Test myScreenSize = get(0,'ScreenSize'); myFig = figure('Name','GUI Test', 'Position',[30 myScreenSize(4)/3 640 480]); h1 = uicontrol; set(h1,'String','Load file','Position',[0 448 128 32],'FontSize',12); cmd='[FileName,PathName] = uigetfile(''*.*'',''Select the M-file'');'; set(h1,'Callback',cmd); [FileName,PathName] = uigetfile('*.*','Select the M-file'); file=[PathName FileName]; fid=fopen(file,'r'); A=fread(fid,[10 10],'uint8'); T=rand(10,10); B=A.*T; %%% h2=uicontrol; set(h2,'String','Preview','Position',[480 0 80 32],'Callback','figure,contourf(T);'); out=1; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.136.25.182

06/07 13:40, , 1F
宣告globle變數 T 應該可以
06/07 13:40, 1F
文章代碼(AID): #1FnuY9Zf (MATLAB)
文章代碼(AID): #1FnuY9Zf (MATLAB)