开发者

Concatenate arrays of subclasses of the same superclass in MATLAB [duplicate]

This question already has answers here: Matlab Polymorphism (2 answers) Closed 5 months ago.

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜