Concatenate arrays of subclasses of the same superclass in MATLAB [duplicate]
I have the fol开发者_StackOverflow社区lowing structure in matlab
superClass < handle
subClassA < superClass
subClassB < superClass
say I have a vector A of subClassA and a vector B of subClassB.
I would like to combine them like this:
superVector = [A B];
but Matlab doesn't like this. What's the proper way to cast the subclass back to the superclass?
cat
Class: matlab.mixin.Heterogeneous Package: matlab.mixin
Concatenation for heterogeneous arrays
this solves your problem...old post, i know
Nevermind - it's impossible
matlab oop help
MATLAB does not allow you to create arrays containing a mix of superclass and subclass objects because an array can be of only one class. If you attempt to concatenate objects of different classes, MATLAB looks for a converter method defined by the less dominant class (generally, the left-most object in the expression is the dominant class).
精彩评论