Effacer les filtres
Effacer les filtres

Math Question_ Combination

2 vues (au cours des 30 derniers jours)
Kyle
Kyle le 28 Juin 2011
Hi,
Let say i have 10 location. I wana test 3 location at a time.
i think there are 10C3=120 combination.(assuming order of the location is not important).
My question is how do i list all the combination in an array?
For example [1 2 3,1 2 4, 1 2 5 ,. . . . . till the 120th]

Réponse acceptée

Oleg Komarov
Oleg Komarov le 28 Juin 2011
nchoosek(1:10,3)
  3 commentaires
Kyle
Kyle le 28 Juin 2011
:X i dint even know there is such a command.
Oleg Komarov
Oleg Komarov le 28 Juin 2011
There are many valuable contributions on the FEX which cover combinatorics. I personally use combinator.

Connectez-vous pour commenter.

Plus de réponses (1)

Sean de Wolski
Sean de Wolski le 28 Juin 2011
That's a fun little challenge before lunch break:
[xx yy zz] = ndgrid(1:10);
vals = unique(sort([xx(:),yy(:),zz(:)],2),'rows');
vals(any(~diff(vals,1,2),2),:) = [];
  1 commentaire
Kyle
Kyle le 28 Juin 2011
Thanks
XD tat was too less of a challenge for u.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Elementary Math 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