Handle of a figure
12 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(2 个)
Walter Roberson
2016-3-24
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 个评论
Walter Roberson
2016-3-25
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.
Joseph Cheng
2016-3-24
编辑:Joseph Cheng
2016-3-24
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)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!