Object Value (C++ equivalent of a pointer?)
14 views (last 30 days)
Show older comments
When I type in the commands:
format long
x=1:10; y=sin(x); h1=plot(x,y)
MATLAB returns something like:
h1 =
1.218110018310547e+005
What does that number (1.218110018310547e+005) represent? Is it a pointer like in C++, where that number somehow represents a place in memory? The number seems to change every time I run the command. All object handles I've seen seem to have a number like this assigned to it, so are all MATLAB objects like C++ pointers?
Thank you
0 Comments
Accepted Answer
Steven Lord
on 22 May 2018
That is a handle to a Handle Graphics object in a release prior to release R2014b. You should not try to compute with it, or expect it to be the same each time you run this code. MATLAB knows how to associate that handle with the graphics object on screen. If you want to access the Handle Graphics object displayed on screen, just refer to h1 rather than trying to type that number in your code.
FYI, in release R2014b we made a major change to the graphics system. As of release R2014b, Handle Graphics object handles are handle object rather than double arrays.
3 Comments
Guillaume
on 22 May 2018
what was the double array used for
You could indeed think of it as an opaque C++ pointer to an object. What it actually is is not documented and its actual value is of no relevance to you. The only thing you can do with it is get it from matlab and pass it back to matlab.
do MATLAB handle objects act like pointers
Depends what you mean by that. Again, it's an opaque reference to an object that you pass around and whose actual value is not important.
More Answers (0)
See Also
Categories
Find more on Code Execution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!