With permute and reshape -
reshape(permute(A,[3 2 1]),size(A,3),[])
Run Example -
>> A A(:,:,1) = 7 1 7 5 3 4 8 5 9 4 2 6 A(:,:,2) = 7 7 2 4 7 6 5 6 3 2 9 3 A(:,:,3) = 7 7 5 3 3 9 2 8 5 9 2 3 >> reshape(permute(A,[3 2 1]),size(A,3),[]) ans = 7 1 7 5 3 4 8 5 9 4 2 6 7 7 2 4 7 6 5 6 3 2 9 3 7 7 5 3 3 9 2 8 5 9 2 3
source share