How to Reshape a matrix

Hello and a nice day to all,
i have a simple question about matrices.
i have a matrix with the dimention 3-by-5:
a = [50,2,3,5,2; 35,3,2,1,3; 27,3,2,1,1]
how do i make it a column only matrix of 1-by-15 like this;
b = [50,2,3,5,2,35,3,2,1,3,27,3,2,1,1]
i've used a(:) but the the order is not what i wanted. I want it exactly to be in the same order as in matrix 'b' above. Is there a function or a simple way to do this ? thanks in advance...

 Respuesta aceptada

Thomas
Thomas el 2 de Oct. de 2012
Editada: Thomas el 2 de Oct. de 2012

0 votos

use
b=reshape(a',1,[])

4 comentarios

tarmizi adam
tarmizi adam el 2 de Oct. de 2012
Thanks for the reply. But the order is not the way i want it. using b= reshape(a,1,[]) produces the following;
b = [50,35,27,2,3,3,3,2,2,5,1,1,2,3,1]
but i want it to be exactly like the following;
b = [50,2,3,5,2,35,3,2,1,3,27,3,2,1,1]
can this be done ?
José-Luis
José-Luis el 2 de Oct. de 2012
You missed the transpose...
The apostrophe ' is important.
Thomas
Thomas el 2 de Oct. de 2012
Notice the transpose on the a .. it is a'
reshape(a',1,[])
which gives
b = [50,2,3,5,2,35,3,2,1,3,27,3,2,1,1]
tarmizi adam
tarmizi adam el 2 de Oct. de 2012
Omg ! Silly me... Thanks tom !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Oct. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by