Object Value (C++ equivalent of a pointer?)
조회 수: 14 (최근 30일)
이전 댓글 표시
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
채택된 답변
Steven Lord
2018년 5월 22일
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
Guillaume
2018년 5월 22일
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!