Object Value (C++ equivalent of a pointer?)

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

 Réponse acceptée

Steven Lord
Steven Lord le 22 Mai 2018

0 votes

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 commentaires

Eddie Ball
Eddie Ball le 22 Mai 2018
Ok, thank you. So, in releases prior to R2014b, what was the double array used for?
In general for releases subsequent to R2014A do MATLAB handle objects act like pointers?
Guillaume
Guillaume le 22 Mai 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.
Eddie Ball
Eddie Ball le 22 Mai 2018
Ahh ok, that's over my head haha, but thank you for the explanation!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Code Execution dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by