MATLAB: Hi everyone, could you please help me in Vectorization of the 3d matrix. thanks in advance

reshape

for eg: consider a matrix of size 2*3*2. a = [4 5 6;1 2 3],[0,1,2;0 7 8] i would like the output as a= [1 2 3 4 5 6],[0 7 8 0 1 2]. that is of size 1*6*2.

Best Answer

>> a
a(:,:,1) =
4 5 6
1 2 3
a(:,:,2) =
0 1 2
0 7 8
>> result = reshape(fliplr(permute(a,[2 1 3])),[1 6 2])
result(:,:,1) =
1 2 3 4 5 6
result(:,:,2) =
0 7 8 0 1 2