MATLAB: How to reshape the matrix A to B

MATLABmatrix array

How to reshape my matrix A to B ??
A(:,:,1)=[ 8, 1, 6 ;…
3, 5, 7 ;…
4, 9, 2 ]
A(:,:,2)=[16, 2, 12 ;…
6, 10, 14 ;…
8, 18, 4 ]
A(:,:,3)=[24, 3, 18 ;…
9, 15, 21 ;…
12, 27, 6 ]
B= 8 1 6
3 5 7
4 9 2
16 2 12
6 10 14
8 18 4
24 3 18
9 15 21
12 27 6

Best Answer

B = reshape(permute(A,[2 1 3]),3,[])'