Matrix Permutation to generate another Matrix

2 ビュー (過去 30 日間)
Sarah
Sarah 2021 年 3 月 3 日
コメント済み: Sarah 2021 年 3 月 3 日
Hello,
I have matrix v. I used p = perms(v) to produce results p. P goes on and on for a ways. I just shared a snip of what it is doing.
What would be the way to do this so I would get the results shown below? The order cannot change. Like you cant swap column 1 and 2. Would it be better to randamize each column instead? Thanks!
p =
2 6
2 3
2 5
1 6
13
15
7 6
7 3
7 5

採用された回答

Walter Roberson
Walter Roberson 2021 年 3 月 3 日
v = [2 6; 1 3; 7 5]
v = 3×2
2 6 1 3 7 5
[t1, t2] = ndgrid(v(:,1), v(:,2));
p = [t1(:), t2(:)];
p
p = 9×2
2 6 1 6 7 6 2 3 1 3 7 3 2 5 1 5 7 5
  1 件のコメント
Sarah
Sarah 2021 年 3 月 3 日
ahh thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by