How to convert a column back into matrix?

3 ビュー (過去 30 日間)
Explorer
Explorer 2016 年 3 月 23 日
編集済み: Stephen23 2016 年 3 月 23 日
A matrix can be converted in column using matrix(:) but how to convert it back into matrix of same order?

採用された回答

Guillaume
Guillaume 2016 年 3 月 23 日
If you don't know what the original size of the matrix was, then you of course can't since matlab does not keep the information.
If you do, use reshape:
A = randi([1 20], 10, 20, 30);
B = A(:);
AA = reshape(B, 10, 20, 30);
isequal(A, AA) %will return true
Note that A(:) is equivalent to
reshape(A, [], 1)
  1 件のコメント
Explorer
Explorer 2016 年 3 月 23 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

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