Handle of a figure

23 views (last 30 days)
Gennaro Arguzzi
Gennaro Arguzzi on 24 Mar 2016
Commented: Walter Roberson on 25 Mar 2016
Hi, I read that the command gcf is the handle of the current figure. What is an handle? If is a pointer, why it does not contain an address? Thank you for your help.

Answers (2)

Walter Roberson
Walter Roberson on 24 Mar 2016
A "handle" gives information about where to look for something, but a "handle" is not necessarily an address. Handles are used especially in cases where something is managing memory on the user's behalf, as the actual location of the data might move in memory but the "handle" will stay the same. Object #792 stays object #792 no matter where it gets placed in memory.
  1 Comment
Walter Roberson
Walter Roberson on 25 Mar 2016
In R2014a and earlier, floating point numbers were used for the handles. They often gave the impression of having some structure, but the meaning was undocumented. In any case the floating point number was used as a reference to locate the graphics object. User-created figures were typically given handles that were integral but still floating point. They were more or less "serial numbers", fixed information that would allow MATLAB to uniquely decide which object was being referred to.
R2014b and later, graphics objects get handles in the sense of object-oriented handles sense. These are not displayable (attempts to display them would give a brief brief summary of the object.) They are as close to addresses as MATLAB uses for its objects for public presentation. MATLAB does internally use addresses for some things, but when you are not in the middle of a mex routine, anything can be moved around in memory.

Sign in to comment.


Joseph Cheng
Joseph Cheng on 24 Mar 2016
Edited: Joseph Cheng on 24 Mar 2016
You should rephrase your question to what are you trying to accomplish with the handle of the current figure. getframe(gcf) does not return the handle. getframe(gcf) as described by the help documentation http://www.mathworks.com/help/matlab/ref/getframe.html (which you really should read first before posting) basically as stated by them
"F = getframe(fig) captures the figure identified by fig. Specify a figure if you want to capture the entire interior of the figure window, including the axes title, labels, and tick marks. The captured movie frame does not include the figure menu and tool bars."
to get the handles see http://www.mathworks.com/help/matlab/ref/gcf.html which is gcf. handles from my knowledge are not pointers but the item that MATLAB "handles" the item. So by obtaining the handles through gcf or defining before hand you can modify the properties that matlab usually hides from the workspace. But that's my superficial understanding of matlab handles. Someone please correct me if i'm wrong as i don't have much time to google it at the moment. (that or i've forgotten what pointers are)

Categories

Find more on Graphics Object Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!