MATLAB: How to merge three matrix into one

functionmatlab functionmatrix

if i have three matrix with different size like this
A = [ 1 1 0 0 1 0
1 0 1 0 0 1
1 1 0 1 0 1
0 1 0 1 0 0 ]
B = [ 2 1 0
1 1 1
2 1 1
1 1 0 ]
C = [ 0 1 0 0 0 0
3 2 1 2 1 2 ]
And i want to merge them like this ( A is the middle , C above A and B on the Right of A )
D = [ 0 1 0 0 0 0
3 2 1 2 1 2
1 1 0 0 1 0 2 1 0
1 0 1 0 0 1 1 1 1
1 1 0 1 0 1 2 1 1
0 1 0 1 0 0 1 1 0 ]

Best Answer

If you want to append with zeros
A = [ 1 1 0 0 1 0
1 0 1 0 0 1
1 1 0 1 0 1
0 1 0 1 0 0 ]
B = [ 2 1 0
1 1 1
2 1 1
1 1 0 ]
C = [ 0 1 0 0 0 0
3 2 1 2 1 2 ]
ma=size(A,2)
mb=size(B,2)
[nc,mc]=size(C)
m=max(mc,mb+ma);
C=[C zeros(nc,m-mc)];
out=[C;A B]