2D array to 1D with rows appending after another row

how do i go from A =[1 2 3 ; 4 5 6] to A = [1 2 3 4 5 6]
I tried reshape(A,1,6) it gives me [1 4 2 5 3 6]

 Respuesta aceptada

A =[1 2 3 ; 4 5 6] ;
iwant = reshape(A',1,[])
iwant = 1×6
1 2 3 4 5 6

1 comentario

To make the intent clearer and the code more robust, it is better to use TRANSPOSE:
reshape(A.',1,[])
% ^^

Iniciar sesión para comentar.

Más respuestas (1)

VBBV
VBBV el 27 de Mzo. de 2023
A = A.'
A(:)

Categorías

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

Productos

Versión

R2023a

Etiquetas

Preguntada:

el 27 de Mzo. de 2023

Comentada:

el 27 de Mzo. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by