行列の並べ替え

13 views (last 30 days)
Jun
Jun on 11 Jan 2019
Commented: Jun on 18 Jan 2019
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
Jun
Jun on 15 Jan 2019
返信ありがとうございます。
お教えいただいた内容から、どのように62481×1 doubleのデータの並べ替えをしたらよいかわかりません。
ご教授いただけないでしょうか。
Kazuya
Kazuya on 15 Jan 2019
あとは jiro さんの言う通り
A(id)
を実行するだけかと思います。下に回答しますので、まずは試してみて、うまくいかなかったらその詳細とともにコメントください。

Sign in to comment.

Accepted Answer

Kazuya
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です。
  1 Comment
Jun
Jun on 18 Jan 2019
返信が遅くなり失礼しました。
無事に解決しました。大変ありがとうございました。

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!