MATLAB: How to concatenate several matrices into one matrix

concatenate

Hello all,
I have 3696 matrices with different number of rows but similar number of columns. Is there a way to concatenate them? I know how to do this with two matrices by C = [A B], but what about these many?
Thank you, Negar

Best Answer

Perhaps, you mistyped. It is C = [A; B] for different number of rows, but similar number of columns. Anyway, how your matrices are named, like do they have a regular pattern? If I assume that they are named as A1, A2, A3..........A3696, then you can use the following technique:
A1 = rand(3,5); % matrix 1
A2 = rand(2,5); % matrix 2
.
.
. % all other matrices in between
.
.
A3696 = rand(1,5); % matrix 3696
B = [];
for k = 1:3696
m = strcat('A',num2str(k));
B = [B; eval(genvarname(m),'=m')];
end