MATLAB: How to generate all possible combination from a sequence

sequence generation

how to generate all possible combination from a n-dimensional vector without repetition of numbers.. i wanted combination of vec = 1:11;
eg:
vec = [1 2 3]
result = [
1 2 3;
1 3 2;
2 3 1;
2 1 3;
3 2 1;
3 1 2];

Best Answer

>> perms(1:3)
ans =
3 2 1
3 1 2
2 3 1
2 1 3
1 2 3
1 3 2
Related Question