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

1 Ansicht (letzte 30 Tage)
Mr M.
Mr M. am 7 Jul. 2018
Beantwortet: Paolo am 7 Jul. 2018
I cannot use perms([1 2 2]) because I dont want 1,2,2 twice.

Antworten (1)

Paolo
Paolo am 7 Jul. 2018
How about calling unique function after perms?
data = unique(perms([1 2 2]),'rows');
data =
1 2 2
2 1 2
2 2 1

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by