combnk
is not recommended. Use the MATLAB function nchoosek
instead. There are no plans to remove
combnk
.
To update your code, change instances of the function name combnk
to nchoosek
. You do not need to change the input arguments. For
example, use C = nchoosek(v,k)
. The output C
contains
all possible combinations of the elements of vector v
taken
k
at a time. Note that C
from
nchoosek
can have a different order compared to the output from
combnk
.
The nchoosek
function has several advantages over the
combnk
function.
nchoosek
also returns the binomial coefficient when the first
input argument is a scalar value.
nchoosek
has extended functionality using MATLAB
Coder™.
nchoosek
is faster than combnk
.