Purpose of guidata(hObject,handles)
이전 댓글 표시
I've been working with GUI GUIDE.
What is the purpose or role of guidata(hObject,handles)?
Thanks,
Amanda
채택된 답변
추가 답변 (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)
arestw ali
2015년 10월 25일
0 개 추천
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
Walter Roberson
2015년 10월 25일
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.
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!