Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Access variable of my GUI from an output figure?

1 Ansicht (letzte 30 Tage)
Elsie
Elsie am 25 Jun. 2014
Geschlossen: MATLAB Answer Bot am 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.
  1 Kommentar
Ben11
Ben11 am 25 Jun. 2014
where do you use setappdata?

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by