nchoose2

버전 3.2.0.1 (2.42 KB) 작성자: Jos (10584)
all combinations of two elements
다운로드 수: 2.7K
업데이트 날짜: 2019/2/28

라이선스 보기

NCHOOSE2 - all combinations of two elements

Y = NCHOOSE2(X) returns all combinations of two elements of the array X. It is the fast, vectorized version of NCHOOSEK(X,2). X can be any type of array. When X is a scalar integer > 1, it returns X*(X-1)/2.

Example:
nchoose2([10 20 30 40])
% -> 10 20
% 10 30
% 10 40
% 20 30
% 20 40
% 30 40

nchoose2({'a','b','c','d','e'})
% -> 'a' 'b'
% 'a' 'c'
% ...
% 'c' 'e'
% 'd' 'e'

See also nchoosek, perms
combn, nchoose, allcomb (on the File Exchange)

인용 양식

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

MATLAB 릴리스 호환 정보
개발 환경: R2018b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Argument Definitions에 대해 자세히 알아보기
도움

받음: nCtwo

줌: nchoose3, VChooseK

Community Treasure Hunt

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

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

added image

3.2.0.0

edited internal comments

3.1.0.0

fixed bug for scalar input

3.0.0.0

When X is a scalar integer > 1, it returns X*(X-1)/2.

2.2.0.0

checked for R2017b, fixed comma's

1.0.0.0

fixed error with input having less than 2 elements