I have the following 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?
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).