All possible combinations of elements in vector with repetitions in MATLAB <p>I have 6 numbers with repetition: 1,2,2,3,3,4. I want all possible combinations using any 4 of the numbers. How will I get that in MATLAB?</p> <p>Generally I use 'nchoosek' function if there is no repetition. </p> <p>Example: <code>A = 1:6; combinations = nchoosek(A,4);</code></p>