nchoosek

Combinatorial function for selecting from a set of items.

Syntax

C=nchoosek(n,k)

C=nchoosek(v,k)

Inputs

n
The number of items from which to choose.
Type: integer
Dimension: scalar
v
The list of items from which to choose.
Type: integer
Dimension: vector
k
The number of items to choose.
Type: integer
Dimension: scalar

Outputs

C
The number of combinations or the list of combinations stored by row.

Examples

Number of combinations example:

C = nchoosek(9,4)
C = 126
List of combinations example:
C = nchoosek([10,20,30,40,50],3)
C = [Matrix] 10 x 3
10  20  30
10  20  40
10  20  50
10  30  40
10  30  50
10  40  50
20  30  40
20  30  50
20  40  50
30  40  50