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

2 vues (au cours des 30 derniers jours)
Mr M.
Mr M. le 7 Juil 2018
Réponse apportée : Paolo le 7 Juil 2018
I cannot use perms([1 2 2]) because I dont want 1,2,2 twice.

Réponses (1)

Paolo
Paolo le 7 Juil 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

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by