The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: MATLAB Concatenation Rules for objects
Replies: 4   Last Post: May 9, 2013 9:41 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Yair Altman

Posts: 1,407
Registered: 3/19/07
Re: MATLAB Concatenation Rules for objects
Posted: May 9, 2013 4:22 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

<kzelechowski@e3tech.local> wrote in message <518a04eb$0$1266$>...
> class (handle (0)) == 'root';
> class (libpointer) == 'lib.pointer';
> class ([ libpointer, (handle (0)) ]) == 'handle';
> % Why? The documentation says: MATLAB does not convert objects to a common
> superclass unless those objects derive from a member of a heterogeneous
> hierarchy.
> % This is not the case:
> isa (libpointer, 'math.mixin.Heterogeneous') == 0;
> % So what is going on here? Moreover:
> numel (superclasses (libpointer)) == 0;
> numel (superclasses (handle (0))) == 0;
> % So if they were heterogeneous, the superclass would be hidden. I am not
> sure how to test for that.

handle() basically wraps its input in a UDD handle object. From Donn Shull's explanation (

handle is a multifaceted and unique term for The MathWorks. There are both UDD and MCOS handle classes. There is a UDD handle package. In terms of the tools we need, handle() is also an undocumented function which converts a numeric handle into a UDD handle object. Depending on your background you may want to think of handle as a cast operator which casts a numeric handle into a UDD object.

By using handle(), you can thus concatenate objects of different types. This can be very useful, as you have seen.

Matlab always shows the array as having the common type. If the concatenated objects are all alike, then their specific common type is displayed; otherwise, the common type is simply the base UDD handle class, which is basically the superclass you were looking for.

The mechanism you're using may be undocumented, but has worked consistently for the past decade or so, and I suspect (although I can't be certain) it will continue to work in the near future.

Note that a fully documented alternative is to use a cell-array, or a struct:

userdata = {0, libpointer};

userdata.numeric = 0; % root
userdata.pointer = libpointer;

Yair Altman

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.