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]

 채택된 답변

KSSV
KSSV 2023년 3월 27일
A =[1 2 3 ; 4 5 6] ;
iwant = reshape(A',1,[])
iwant = 1×6
1 2 3 4 5 6

댓글 수: 1

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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

VBBV
VBBV 2023년 3월 27일
A = A.'
A(:)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

릴리스

R2023a

태그

질문:

2023년 3월 27일

댓글:

2023년 3월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by