Matrix Elements Manipulation (Re-ordering matrices and their elements)

1 回表示 (過去 30 日間)
Pedro Oliveira
Pedro Oliveira 2017 年 10 月 24 日
回答済み: Walter Roberson 2017 年 10 月 24 日
If I have a matrix A,
A = [1,2,3,4,5,6,7,8]
How can I turn it into a 4x2 matrix which assigns the elements row-wise, i.e.
B = [1,2; 3,4; 5,6; 7,8]
In addition, how do I go from B to A?
Thank you in advance for your help and if possible, please explain the functions used, as I wanna understand, not just have a solution.

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 24 日
B = reshape(A,2,4).';
recreated_A = reshape(B.', 1, []);

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by