How to concatenate matrix row wise to get a column vector

37 visualizaciones (últimos 30 días)
I have a matrix
A = [1,2,3,4
5,6,7,8
9,10,11,12]
How do I make it into a column vector by concatenating the rows, such that I get B = [1,2,3,4,5,6,7,8,9,10,11,12]
Thanks!

Respuesta aceptada

Image Analyst
Image Analyst el 19 de Nov. de 2016
Like this:
AColumnVector = reshape(A', [], 1)

Más respuestas (1)

Star Strider
Star Strider el 19 de Nov. de 2016
Another approach:
B = A';
B = B(:)'
B =
1 2 3 4 5 6 7 8 9 10 11 12

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by