Get the "handle number" of a standard handle class
古いコメントを表示
How can I ...
-Get the "handle number" (like the handle number returned when using hdgetset classes(ex : 203.0024)) of a myclass object which is of a "standard" handle class (myclass<handle)
-Store this "handle number" in a text variant
-And then retrieve my original object by this "handle number"
Thanks for you help!!! Gabriel
採用された回答
その他の回答 (3 件)
Andrew Newell
2012 年 2 月 29 日
Setappdata seems best because of the limitations on using the UserData property (see How can I keep track of my GUI object handles?. You can store handles, as in the following example:
x = 1:10;
h = plot(x,x);
ha = @(x) x^2;
setappdata(h,'myHandle',ha)
f = getappdata(h,'myHandle');
f(2)
ans =
4
Daniel Shub
2012 年 2 月 29 日
0 投票
You cannot do this directly. I don't understand why you would want to. Why not just pass the object around? MATLAB is pretty smart about memory management and doesn't make copies of handle object every time they are referenced.
If you really want to do it, you could subclass the handle class with something like myhandle. This new class could have a public property "h" which gets set at creation with a unique number. There are a number of ways that I can think of to keep track of the handle number to guarantee that they are unique. Then just make myclass<myhandle.
6 件のコメント
Walter Roberson
2012 年 2 月 29 日
I _think_ what Gabriel is asking for is an object serialization method. Which MATLAB does have internally but has never exposed.
Daniel Shub
2012 年 2 月 29 日
@Walter, it is possible that I am wrong. I interpreted hdgetset to be hgsetget and the 203.0024 to be a handle to a graphics object.
Walter Roberson
2012 年 2 月 29 日
Hard to say. We'll have to wait for an update from Gabriel.
Gabriel Caron L'Écuyer
2012 年 2 月 29 日
Gabriel Caron L'Écuyer
2012 年 2 月 29 日
Walter Roberson
2012 年 2 月 29 日
Gabriel, object handles that are not handle graphics objects, do *not* have a representation of the kind you are seeking.
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!