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

3 views (last 30 days)
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)];

Accepted Answer

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

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!