MATLAB: Adding multiple arrays into one big array

reshape zeros

Hi,
I have multiple array with different sizes such as A1=(200 by 3000),A2=(280 by 3020).
I will like to create a zeros matrix: A=zeros(480 by 3020) where i'm able to stack each rows of A1 and A2 inside the new array A.
Such that A=[A1;A2]
what should i do?

Best Answer

s1 = size(A1);
s2 = size(A2);
s22 = max(s1(2),s2(2));
A = [A1,zeros(s1(1),s22 - s1(2));A2,zeros(s2(1),s22 - s2(2))];