MATLAB: How to compute Permutation without repetition

permutationwithout repetition

We are trying to create a permutation with a,b,c,d,e,f. Taking 5 at a time. We want all the possible permutation without repetition.

Best Answer

If a, b, c, etc. are different numbers, do this:
v = [a,b,c,d,e,f];
P = perms(v);
P = P(:,1:5);
The matrix P will now contain all possible permutations of five elements selected out of v. There will be 720 rows and 5 columns.
If you had asked for, say, all permutations of five numbers chosen out of a larger number like ten, I would have had to do more work above.