Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Access variable of my GUI from an output figure?

1 vue (au cours des 30 derniers jours)
Elsie
Elsie le 25 Juin 2014
Clôturé : MATLAB Answer Bot le 20 Août 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 commentaire
Ben11
Ben11 le 25 Juin 2014
where do you use setappdata?

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by