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

1 Ansicht (letzte 30 Tage)
Ishan Srivastava
Ishan Srivastava am 27 Mär. 2023
Kommentiert: Stephen23 am 27 Mär. 2023
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]

Akzeptierte Antwort

KSSV
KSSV am 27 Mär. 2023
A =[1 2 3 ; 4 5 6] ;
iwant = reshape(A',1,[])
iwant = 1×6
1 2 3 4 5 6
  1 Kommentar
Stephen23
Stephen23 am 27 Mär. 2023
To make the intent clearer and the code more robust, it is better to use TRANSPOSE:
reshape(A.',1,[])
% ^^

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

VBBV
VBBV am 27 Mär. 2023

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by