nchoosek - non consecutive numbers

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.

 Accepted Answer

Walter Roberson
Walter Roberson on 27 Mar 2018
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.

More Answers (0)

Categories

Find more on Elementary Math in Help Center and File Exchange

Asked:

on 27 Mar 2018

Commented:

on 27 Mar 2018

Community Treasure Hunt

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

Start Hunting!