Info

此问题已关闭。 请重新打开它进行编辑或回答。

Access variable of my GUI from an output figure?

1 次查看(过去 30 天)
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.

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by