C = nchoosek(v,k) returns
a matrix containing all possible combinations of the elements of vector v taken k at
a time. Matrix C has k columns
and n!/((n–k)! k!) rows, where n is length(v).

Number of selected choices, specified as a scalar value that
is real and nonnegative. k can be any numeric type.
However, nchoosek(n,k) requires that n and k be
the same type or that at least one of them be of type double.

There are no restrictions on combining inputs of different types
for nchoosek(v,k).

Binomial coefficient, returned as a nonnegative scalar value. b is
the same type as n and k. If n and k are
of different types, then b is returned as the nondouble
type.

All combinations of v, returned as a matrix
of the same type as v. Matrix C has k columns
and n!/((n–k)! k!) rows, where n is length(v).

Each row of C contains a combination of k items
chosen from v. The elements in each row of C are
listed in the same order as they appear in v.

Limitations

When b = nchoosek(n,k) is sufficiently
large, nchoosek displays a warning that the result
might not be exact. In this case, the result is only accurate to 15
digits for double-precision inputs, or 8 digits for single-precision
inputs.

C = nchoosek(v,k) is only practical
for situations where length(v) is less than about 15.