MATLAB: How to vertically concatenate two tables with different sizes

concatenate two tables with different sizes

For example:
>> A = table(['A1';'A1';'A1'],[1;1;1],[1;1;1],...
'VariableNames',{'Var1' 'Var2' 'Var3'})
A =
Var1 Var2 Var3
____ ____ ____
A1 1 1
A1 1 1
A1 1 1
>> B = table(['B1';'B1'],[2;2],[2;2],...
'VariableNames',{'Var1' 'Var2' 'Var4'})
B =
Var1 Var2 Var4
____ ____ ____
B1 2 2
B1 2 2
How can I vertically concatenate A and B like the following? Thanks!
Var1 Var2 Var3 Var4
____ ____ ____ ____
A1 1 1 NAN
A1 1 1 NAN
A1 1 1 NAN
B1 2 NAN 2
B1 2 NAN 2

Best Answer

outerjoin(A,B,'MergeKeys', true)
It took me a few minutes to find the right command.