| Description |
B = ALLCOMB(A1,A2,A3,...,AN) returns all combinations of the elements in A1, A2, ..., and AN. B is P-by-N matrix is which P is the product of the number of elements of the N inputs.
Empty inputs yields an empty matrix B of size 0-by-N. Note that previous versions (1.x) simply ignored empty inputs.
Example:
allcomb([1 3 5],[-3 8],[0 1]) ;
1 -3 0
1 -3 1
1 8 0
...
5 -3 1
5 8 0
5 8 1
ALLCOMB(A1,..AN,'matlab') causes the first column to change fastest. This is more consistent with matlab indexing. Example:
allcomb(1:2,3:4,5:6,'matlab') %->
1 3 5
2 3 5
1 4 5
...
2 4 6
This functionality is also known as the cartesian product.
See also <COMBN> here on the FEX |