Re-arranging columns into rows

1 回表示 (過去 30 日間)
Olu adroit
Olu adroit 2016 年 1 月 13 日
回答済み: Ralf 2016 年 1 月 13 日
Hi guyz, My script generates a N x N matrix where N can be any integer. I would like to re-arrange all the N columns in series into a single 1 x N*N matrix. E.g For a 3 x 3 matrix A = (1,10,19;2,11,20;3,12,21), I would like to re-arrange A to obtain B = (1,2,3,10,11,12,19,20,21). For a 2 x 2 matrix C = (1,25;3,27), i would like to obtain matrix D = (1,3,25,27). N can take values up to 400. I am beginner and Your help is kindly welcome. thanks in advance.

採用された回答

Ralf
Ralf 2016 年 1 月 13 日
Isn't that simply done using the reshape function?
B = reshape(A, 1, N*N);
Regards, Ralf

その他の回答 (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