Table column with different subclasses of a superclass

I am try to combine tables that have a column of objects. The objects in these columns are both subs of a common superclass, but are different subs. When I try to combine tables, I get an error saying "Could not concatenate the table variable 'var' using VERTCAT.".
My object structure resembles the following:
classdef (Abstract) super
% Some stuff
end
classdef sub1 < super
% Some stuff
end
classdef sub2 < super
% Some stuff
end
Is there a way for me to have both of these tables, with different sub definitions in the same 'var' column, combine into one table? Can I assign the type of 'var' column to type super and would this allow vertcat to work?

1 件のコメント

Luna
Luna 2019 年 1 月 11 日
Could you please share sample tables with the code?

サインインしてコメントする。

 採用された回答

Steven Lord
Steven Lord 2019 年 1 月 11 日

2 投票

So you want a heterogeneous array?

1 件のコメント

Alex Luck
Alex Luck 2019 年 1 月 12 日
This worked perfectly. I simply inherited from matlab.mixin.Heterogeneous in my superclass and they now combine as intended.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2018b

質問済み:

2019 年 1 月 11 日

コメント済み:

2019 年 1 月 12 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by