nchoosekcom

버전 1.0.1 (1.81 KB) 작성자: Jos (10584)
NCHOOSEK with its complementary combinations
다운로드 수: 31
업데이트 날짜: 2019/4/28

라이선스 보기

NCHOOSEKCOM Binomial coefficient or all combinations, and its complement

With one output argument, C = NCHOOSEKCOM (..) is the same as C = NCHOOSEK(..). For a vector V, C = NCHOOSEKCOM(V, K) returns a matrix with all possible combinations of the elements of V, taken K at a time. See NCHOOSEK for details.

With two output arguments, [C, D] = NCHOOSEKCOM (V, K) also returns the complementary combinations in D. C and D have the same number of rows: when the j-th row of C contains a combination of K elements of V, then the j-th row of D contains the other elements. In other words, [C(j,:) D(j,:)] is the same as V, except for order.

For a positive scalar N, [C D] = nchoosekcom(N, K) will return the binomial coefficient (= N!/K!(N-K)!) in both C and D, since the number of combinations of N things taken K at a time equals the number of combinations of N things taken (N-K) at a time.

Example:
[C, D] = nchoosekcom(1:5, 2)
% C: - D:
% 1 2 - 3 4 5
% 1 3 - 2 4 5
% 1 4 - 2 3 5
% ..
% 3 4 - 1 2 5
% 3 5 - 1 2 4
% 4 5 - 1 2 3

인용 양식

Jos (10584) (2024). nchoosekcom (https://www.mathworks.com/matlabcentral/fileexchange/71389-nchoosekcom), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2018a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.1

update example in description

1.0.0