Programatically (i.e. not using guide) accessing an edit box in another function
Afficher commentaires plus anciens
hi. I have create a figure and want to manually create a button and edit box on it too
%Add push button and edit boxes to analyse specific point
f1=figure;
ax1=subplot(1,1,1)
pb1 = uicontrol('Style', 'pushbutton',...
'String', {'Go'},...
'Position', [10 70 80 20],...
'Callback', @(src,evt) IntegratedIntensity( src, evt, ax1,handles ));
edx = uicontrol('Style', 'edit',...
'String', {'x pixel'},...
'Position', [10 40 40 20]);
I have connected the pushbutton to a function:
function IntegratedIntensity(source,event,ax,handles)
x=str2num(get(handles.edx,'String'));
However, when I call this function, the error indicates the edit box isn't recognised.
Reference to non-existent field 'edx'.
2 commentaires
Jason
le 4 Avr 2017
Adam
le 4 Avr 2017
handles.figure1 is a handle to the figure (assuming that is what you have named the field if you are doing it programmatically - it seems to be judging by your error).
If it where in GUIDE you would get the handles structure from this as
handles = guidata( hGUI );
where hGUI would be the 4th argument to your CumSum function, not 'handles' because it is the handle to your GUI figure.
In a programmatic UI though it depends entirely how you have programmed it as to how you need to access things. If you use a nested function then you don't need to pass anything in often. If you do it in a class then the object will usually contain everything you want so is the only needed argument.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!