Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Access variable of my GUI from an output figure?

조회 수: 1 (최근 30일)
Elsie
Elsie 2014년 6월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
My GUI can output a figure which shows all the result. I use uicontrol to add a few buttons in the figure. But i don't know how to access my GUI variable from these buttons. Pls help. I have tried setappdata and getappdata. But still not working. Any one give a guide. Very grateful for your help.
function BtnBuffer_Callback(hObject, eventdata, handles)
handles.output =hObject;
BatchAnalysis(hObject, eventdata, handles);
guidata(hObject,handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function BatchAnalysis(hObject, eventdata, handles)
...
...
figureHandle = figure; %output a figure
h = handles.BtnCrop;
x = getappdata(h,'cropX');
y = getappdata(h,'cropY');
u1 = uicontrol('Style','push',...
'parent', figureHandle,...
'pos',[1470 500 80 80],...
'string','Back',...
'Enable','off',...
'Callback',@buttonBack);
...
...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function buttonBack(hObject, eventdata, handles)
handles.output = hObject;
set(u2, 'Enable','on');
if(ind > 1)
set(u1,'Enable','on');
ind = ind-1;
hold on
h = handles.BtnCrop;% the crop button in GUI, i want to capture my crop mark
x = getappdata(h,'cropX');
y = getappdata(h,'cropY');
batchPlot(final,blockImage,row,col,mag,pha,ind,x,y);
if(ind == 1)
set(u1,'Enable','off');
end
else
set(u1,'Enable','off');
end
guidata(hObject,handles);
e.g. in function buttonBack, i want to access handles.BtnCrop in my GUI, error says no such reference. What can i do? I have been suffering this problem for quite a few days and still can't figure out.
  댓글 수: 1
Ben11
Ben11 2014년 6월 25일
where do you use setappdata?

답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by