Math Question_ Combination
3 ビュー (過去 30 日間)
古いコメントを表示
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]
0 件のコメント
採用された回答
Oleg Komarov
2011 年 6 月 28 日
nchoosek(1:10,3)
3 件のコメント
Oleg Komarov
2011 年 6 月 28 日
There are many valuable contributions on the FEX which cover combinatorics. I personally use combinator.
その他の回答 (1 件)
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),:) = [];
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!