Hi everyone,
The MATLAB documentation states:
"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."
The MATLAB documentation for function cast() states:
"B = cast(A, newclass) converts A to class newclass, where newclass is the name of a built-in data type compatible with A."
Since we can't use the cast() function to convert a subclass to its superclass, how else can we perform the necessary conversion, in this or any general context..?
For example:
classdef MySuperClass...endclassdef MySubClass < MySuperClass...end% Create subclass object:
mySubClassObj = MySubClass(..);% Try to cast to superclass:
mySubClassObj = cast(mySubClassObj,'MySuperClass');Error using castUnsupported class for conversion.
Any guidance / suggestions appreciated,
Thanks, Brad
Best Answer