行列の並べ替え
13 views (last 30 days)
Show older comments
62481×1 doubleのデータがあります。これを350×350に並べ替えたいと思っています。
ただ、問題はその並べ変えの仕方です。データの(1,1)を1 (2,1)を2・・・とすると、
1 2 4 7 11 ・・・
2 3 5 8 12・・・
4 5 6 9 13・・・
7 8 9 10 14・・・
11 12 13 14 15・・・
・
・
・
上記のように、複雑ではありますが、規則的に並べ替えたいと思っていますがうまくできません。
お力をお貸しください
6 Comments
Kazuya
on 15 Jan 2019
あとは jiro さんの言う通り
A(id)
を実行するだけかと思います。下に回答しますので、まずは試してみて、うまくいかなかったらその詳細とともにコメントください。
Accepted Answer
Kazuya
on 15 Jan 2019
まず、並びを表す行列を作る。
N = 350; % 行列サイズ(任意に決めてください)
base = 1+cumsum(0:N-1);
A = base + (0:N-1)';
uA = triu(A)+triu(A,1)';
62481×1 doubleのデータを M とすると、
Msorted = M(uA);
でOKです。
More Answers (0)
See Also
Categories
Find more on 線形代数 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!