I want to reduce a two dimensional matrix to row vector.
But using reshape
with large matrices is really slow. The other alternative is to use colon
, but i want matrix's transpose to be colon and not the matrix itself.
e.g.
A=magic(3)
A =
8 1 6
3 5 7
4 9 2
A(:)
will stack up all the columns one by one. but i am looking for something like this:
AA=A(2:3,:)';
and then reshape or colon AA instead of A.
The issue is i dont want to define additional variable like AA
.
Is there anyway to reduce dimension of two dimensional matrix without reshape
?
A(2:3,:)'
(orA(2:end,:).'
) without assigning it to a variable? – Luis Mendoreshape
that takes time, but the need to copy the reshaped matrix into a different memory location. – Shai