Purpose of guidata(hObject,handles)
Mostrar comentarios más antiguos
I've been working with GUI GUIDE.
What is the purpose or role of guidata(hObject,handles)?
Thanks,
Amanda
Respuesta aceptada
Más respuestas (2)
This stores the variable named 'handles' in the guidata of the object with handle HObject.
I assume you saw this in the Openfcn of a GUIDE GUI, correct? If so, then this line is simply storing a structure called 'handles', which contains the handles to all visible graphics objects, in the guidata of the figure. From anywhere else you can access this structure by calling GUIDATA(hfig). For example, say you have a GUIDE GUI named mygui. Do this at the command line:
H = mygui; % Returns the handle of the figure into H.
guidata(H)
1 comentario
Amanda
el 1 de Sept. de 2012
arestw ali
el 25 de Oct. de 2015
0 votos
hello everyone what is the different between (hObject, eventdata, handles, varargin) how can i related between for exmp. the pushbutton and pop,text,axis thanx a lot
1 comentario
Walter Roberson
el 25 de Oct. de 2015
hObject is the handle to the object whose callback is being executed.
eventdata is empty for most kinds of callbacks, but for some kinds of callbacks it gives additional information about what triggered the callback. For example a key press function callback will have information about which key sequence triggered the callback.
handles, in the context you use, is a structure containing whatever data has been stored in it. When you are using GUIDE, at the very least it will have one field for every graphics object you created using GUIDE, with the field named the same as the Tag you used for the object. For example if you have a pushbutton1 and an editbox1 then handles would be a structure with fields "pushbutton1" and "editbox1", and the value of those fields created by default would be the handles of the respective graphics object. It is common to also store other non-handle information into handle, such as the way Sven showed storing a counter there.
varargin is for variable length argument data; see http://www.mathworks.com/help/matlab/ref/varargin.html. It allows the routine to be programmed to accept optional parameters.
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!