That is what nchoosekit does:
M = [ 1 2 3 4 ];
R = nchoosek(M,2);
returns:
R =
1 2
1 3
1 4
2 3
2 4
3 4
I don’t know if this is your intention, but it nchoosekis a Matlabs implementation. Number of k-combinations from a given set S of n elements without repetition ( Wikipedia )
nchoosek . File Exchange , (!!) .
, . .
M = [ 21 42 123 17 ];
:
R =
21 42
21 123
21 17
42 123
42 17
123 17