Reputation: 335
I have a 10x10 matrix (called A
) and I'd like to make a 1x100 vector (called B
) out of the rows of A
. And I'm not sure if there is a fast way to program this in MATLAB.
Upvotes: 1
Views: 310
Reputation: 30589
Transpose A
and read out the elements linearly:
At = A.'; %' transpose to read across A
B = At(:).'; %' (:) creates column vector, transpose with .'
Short example:
>> A=magic(3)
A =
8 1 6
3 5 7
4 9 2
>> At = A.';
>> B = At(:).'
B =
8 1 6 3 5 7 4 9 2
Upvotes: 3