combinations

버전 1.0.0.1 (3.03 KB) 작성자: Gautam Vallabha
Returns combinations of a set of numeric or cell vectors (uses a memory-efficient algorithm)
다운로드 수: 2.4K
업데이트 날짜: 2016/9/1

라이선스 보기

C = COMBINATIONS(V1, V2, V3, ...Vn) returns the set of combinations formed by taking the first element from vector V1, the second element from vector V2, the third from vector V3, and so on.
C is a KxN matrix, where K is the total
number of combinations, and N is the number
of (non-empty) input vectors.

V1, V2, ... Vn can be either numeric or cell arrays.

C = COMBINATIONS(V1, V2, V3, ...Vn, CLASSNAME) specifies that all the numeric vectors have numeric type CLASSNAME (e.g., 'int8', 'single').

Examples:

c = combinations(1:5, 1:2)
c = combinations(1:5, 1:2, 'int8')
c = combinations(0:1,0:1,0:1,0:1,0:1,0:1,0:1,0:1,0:1,'int8');

c = combinations({'aa','bb'}, 1:3)
c = combinations({'aa','bb'}, {[1 2] [4 5 6]}, [true false])

----------------
MOTIVATION (in the spirit of reducing FileEx redundancy and clutter)

There are other FileExchange entries for calculating combinations:
ALLCOMB (Filex# 10064)
SETPROD (FileEx# 5898)
CARTPROD (FileEx# 5475)

This implementation differs in two ways.

1) It allows combination of arbitrary cell arrays, and mixtures of cell and numeric arrays.

2) It use a memory-efficient algorithm that does not use intermediate matrices; furthermore, when CLASSNAME is specified, the specified numeric datatype is used consistently (there is no internal conversion from 'double'). This efficiency is relevant when the input consists of many small vectors or a few very large vectors.

인용 양식

Gautam Vallabha (2024). combinations (https://www.mathworks.com/matlabcentral/fileexchange/23080-combinations), MATLAB Central File Exchange. 검색됨 .

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

줌: VChooseK

Community Treasure Hunt

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

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

Updated license

1.0.0.0