Error using vertcat. Dimensions of arrays being concatenated are not consistent.

1 次查看(过去 30 天)
Hi I am trying to concatenate 2 tables both of them have the same number of columns but one of the columns, which is called PartyX, varies in length, so in Table1 PartyX is a 1X14 cell array
{'U'} {'XXX'} {'MP'} {'PAFT'} {'100659'} {'101659'} {'MFTP'} {'1000dbd659'} {'dsdad'} {'0'} {'XXX'} {'GB'} {'GB'} {'XXX'}
and in Table2
PartyX is a 1X2 cell array
{'ABC'} {'XXX'}
Could not concatenate the table variable 'PartyX' using VERTCAT.
Caused by:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Any suggestions as to how I can resolve this
I am using this to concatenate
Table1 = [struct2table(orderfields(table2struct(Table1)),'asArray',1) ; struct2table(orderfields(table2struct(Table2)),'asArray',1)];

采纳的回答

Arthur Roué
Arthur Roué 2020-8-5
You can merge table with outerjoin function.
Table1 = outerjoin(Table1, Table2, 'MergeKeys',true)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by