If have a set of 12 numbers (eg. 5, 7, 13, 14, 17, 18, 21, 24, 27, 35, 37, 39) and I would like to calculate a list of all the possible combinations of those numbers using only 7 of them. How would I do that? I don't care to know all the possible permutations of 7 numbers (that's the next step), just the combinations. Thank you.
Using C = m!/n!(m-n)! where m = 12 and n = 7 I know the result should yield a 7 X 792 matrix.

 Réponse acceptée

Walter Roberson
Walter Roberson le 27 Mar 2018

0 votes

https://www.mathworks.com/help/stats/combnk.html
https://www.mathworks.com/help/matlab/ref/nchoosek.html
Notice the syntax involving v, a vector of specific values.

Plus de réponses (0)

Catégories

En savoir plus sur Elementary Math dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by