Info

This question is closed. Reopen it to edit or answer.

Access variable of my GUI from an output figure?

1 view (last 30 days)
Elsie
Elsie on 25 Jun 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
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.

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!