MATLAB: How to reshape an array in a specific manner

arrayreshape

Hi all,
I was trying to reshape an array in a specific manner, however I couldn't accomplish that. Here is the example:
I have the following array:
a = [1 ; 2 ; 3 ; 1 ; 2 ; 3 ; 1 ; 2 ; 3 ; 1 ; 2 ; 3] ;
Which I would like to reshape to:
A = [1 2 3 ; 1 2 3 ; 1 2 3 ; 1 2 3] ;
How can I do this?
I have tried A=reshape(a, 4, 3) however it is returning A=[1 2 3 ; 2 3 1 ; … etc
Thanks for your help in advance,
KMT

Best Answer

>> reshape(a,3,[]).'
ans =
1 2 3
1 2 3
1 2 3
1 2 3
>>