MATLAB: Matrix manipulation

matrix manipulation

>> A
A =
7 0 6
9 8 7
6 9 7
>> B
B =
3 7 0
6 0 0
1 2 8
>> C
C =
6 0 7
3 4 7
9 3 1
I need to have a matrix which have to store like this
>> Vec
Vec =
7 9 6 0 8 9 6 7 7
3 6 1 7 0 2 0 0 8
6 3 9 0 4 3 7 7 1
the above representing, each location element of all mattices are stored as coloumn.
For this I have written a code like this
>> P=reshape(A,[1 9]);
>> Q=reshape(B,[1 9]);
>> R=reshape(C,[1 9]);
>> Vec=[P;Q;R]
Is there any better way to do this?

Best Answer

Vec=[A(:) B(:) C(:)]'
Related Question