フィルターのクリア

how to convert 2-D array to 1-D array

4 ビュー (過去 30 日間)
Ashraf Hisham
Ashraf Hisham 2018 年 4 月 17 日
コメント済み: Guillaume 2018 年 4 月 17 日
how to convert 2-D array of dimension n*m to 1-D array with length (n*m) if a=[1 2 3;4 5 6;7 8 9] i want a = [1 2 3 4 5 6 7 8 9] so how

採用された回答

Guillaume
Guillaume 2018 年 4 月 17 日

transpose then reshape

a = reshape(a.', 1, [])

その他の回答 (1 件)

Bosong Lin
Bosong Lin 2018 年 4 月 17 日
Hey,
Try this. A = [1,2;3,4]; A = A(:);
  1 件のコメント
Guillaume
Guillaume 2018 年 4 月 17 日
Ashraf wants the reshaping done by row, this would do it by column which is not what is asked. It produces [1;3;2;4] instead of [1,2,3,4]

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

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by