How to generate all permutations of numbers if I have a number twice?

2 ビュー (過去 30 日間)
Mr M.
Mr M. 2018 年 7 月 7 日
回答済み: Paolo 2018 年 7 月 7 日
I cannot use perms([1 2 2]) because I dont want 1,2,2 twice.

回答 (1 件)

Paolo
Paolo 2018 年 7 月 7 日
How about calling unique function after perms?
data = unique(perms([1 2 2]),'rows');
data =
1 2 2
2 1 2
2 2 1

カテゴリ

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