Generate Only a Specific Number of Combinations

I would like to loop through the combinations of 30 take 20 with no repetition and order does not matter. I would only like to compute the first 100 or so combinations as there are over 30,000,000 total combinations. Is there a MatLab function that will allow me to do this? Functions like nchoosek will generate all possible combinations and take a very long time.

2 件のコメント

Matt J
Matt J 2012 年 11 月 26 日
編集済み: Matt J 2012 年 11 月 26 日
What do you mean by the "first 100..."? How in your mind are the combinations ordered?
Nicholas
Nicholas 2012 年 11 月 26 日
Order does not really matter. Any set of 100 will do.

サインインしてコメントする。

 採用された回答

Matt Fig
Matt Fig 2012 年 11 月 26 日
編集済み: Matt Fig 2012 年 11 月 26 日

0 投票

There are several functions on the FEX that do something like this. For instance:
One could also make an index into the set by something like this:
A = [88 44 55 66 33 22 11 99 77 66];
idx = randperm(10,4);
A(idx) % A random sampling of 4 elements of A
So you do this in a loop as many times as needed, storing all the idx values and checking for uniqueness, then after the loop you have the needed random samplings.

その他の回答 (1 件)

Matt J
Matt J 2012 年 11 月 27 日

0 投票

This will generate 120 combinations
A=nchoosek(10,1:3);
N=size(A,1);
Result=[A,repmat(11:27,N,1)];

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2012 年 11 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by