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

16 views (last 30 days)
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]

Accepted Answer

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

Sign in to comment.

More Answers (1)

VBBV
VBBV on 27 Mar 2023
A = A.'
A(:)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!