Math Question_ Combination

조회 수: 3 (최근 30일)
Kyle
Kyle 2011년 6월 28일
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]

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 6월 28일
nchoosek(1:10,3)
  댓글 수: 3
Kyle
Kyle 2011년 6월 28일
:X i dint even know there is such a command.
Oleg Komarov
Oleg Komarov 2011년 6월 28일
There are many valuable contributions on the FEX which cover combinatorics. I personally use combinator.

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

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 6월 28일
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
Kyle
Kyle 2011년 6월 28일
Thanks
XD tat was too less of a challenge for u.

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

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by