我想在MATLAB中創建自己的函數來檢查一些條件,但我不知道如何在那裏發送handles
。最後,我想從這個其他函數的GUI中打印一些文本。我不能直接在此函數中使用handles.t1
,因爲它不能從函數內訪問。我怎麼能通過它?使用「手柄」在GUIDE GUI中在我自己的函數中打印文本
function y = check(tab)
if all(handles.tab == [1,1,1])
set(handles.t1, 'String', 'good');
else
set(handles.t1, 'String', 'bad');
end
end
編輯
註釋,第一個答案之後,我決定把整個回調,我打電話給我的功能:
function A_Callback(hObject, eventdata, handles)
if handles.axesid ~= 12
handles.axesid = mod(handles.axesid, handles.axesnum) + 1;
ax = ['dna',int2str(handles.axesid)];
axes(handles.(ax))
matlabImage = imread('agora.jpg');
image(matlabImage)
axis off
axis image
ax1 = ['dt',int2str(handles.axesid)];
axes(handles.(ax1))
matlabImage2 = imread('tdol.jpg');
image(matlabImage2)
axis off
axis image
handles.T(end+1)=1;
if length(handles.T)>2
check(handles.T(1:3))
end
end
guidata(hObject, handles);
「我自己的功能」可以*更*不明確?這是編程GUI的一部分嗎? GUIDE GUI?隨機MATLAB功能?類定義?腳本?這個函數如何被調用?請參閱:[mcve] – excaza
是的,這是GUIDE GUI。當我寫作「我自己的功能」時,我認爲它與回調函數不同。這個函數被稱爲「檢查」,它檢查數組是否具有與您在「if」中看到的值相同的值。我需要的是知識我怎樣才能在我自己聲明的函數中使用「句柄。(whatever_here)」。 – soommy12