MATLAB: How to find X unique combinations (order doesn’t matter) of X numbers within an array of X numbers.

jackniferandomsampleresample

The question is in the title.
Thanks!

Best Answer

You might just miss the feature of NCHOOSEK that can accept the vector array as input
>> X=rand(1,5)
X =
0.3566 0.3205 0.8137 0.1779 0.9431
>> nchoosek(X,3)
ans =
0.3566 0.3205 0.8137
0.3566 0.3205 0.1779
0.3566 0.3205 0.9431
0.3566 0.8137 0.1779
0.3566 0.8137 0.9431
0.3566 0.1779 0.9431
0.3205 0.8137 0.1779
0.3205 0.8137 0.9431
0.3205 0.1779 0.9431
0.8137 0.1779 0.9431