How many combination will appear

A=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49];
B = nchoosek(A, 7)

답변 (1개)

Roger Stafford
Roger Stafford 2017년 1월 7일

1 개 추천

I hope you have a lot of memory available to matlab! B will be of size 85900584 by 7. That is, there will be 49!/7!/42! combinations.

댓글 수: 3

It occurs to me that what you might have wanted was to generate, say, N random equally likely combinations of seven numbers chosen from among the forty-nine, where N is very much less than the number I quoted above. If so, you could do this:
C = zeros(N,7);
for k = 1:N
C(k,:) = sort(randperm(49,7));
end
dhmhtrhs
dhmhtrhs 2017년 1월 8일
i don't know good english, i want write a example the who are executable for i see doing
I’m not sure I completely understand what you are saying, Dhmhtrhs. I ran the above code on my computer’s version of Matlab, and got the following random result. I chose N = 10, so C has ten rows with each one containing a combination of seven random numbers chosen from among the numbers from one to forty-nine. You are probably interested in more than ten random samples, but probably far less than 49!/7!/42! = 85,900,584.
disp(C)
1 10 14 16 25 32 46
19 21 25 28 30 40 47
7 10 12 25 29 31 35
1 10 12 26 32 38 39
22 24 33 34 35 37 47
10 24 25 28 39 41 43
4 6 23 25 33 37 48
7 11 13 16 19 26 28
7 17 20 26 30 35 37
6 8 17 23 28 34 36

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2017년 1월 7일

편집:

2017년 1월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by