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 日

1 投票

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

1 件のコメント

Stephen23
Stephen23 2023 年 3 月 27 日
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 日

1 投票

A = A.'
A(:)

1 件のコメント

VBBV
VBBV 2023 年 3 月 27 日
Transpose the matrix A and take the vertcat

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

製品

リリース

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