Matlab matrices containing all permutations of a sequence

Hello,

Is there some command in MATLAB that will give me an array of all the possible permutations of a given sequence of numbers?

For example, if I have the sequence 1,2,3, is there a command that will give me the matrix

1,2,3

1,3,2

2,1,3

2,3,1

3,1,2

3,2,1

Not necessarily in that order, but containing all 3! permutations of 1,2,3.

Thanks

Re: Matlab matrices containing all permutations of a sequence

Quote:

Originally Posted by

**rainer** Hello,

Is there some command in MATLAB that will give me an array of all the possible permutations of a given sequence of numbers?

For example, if I have the sequence 1,2,3, is there a command that will give me the matrix

1,2,3

1,3,2

2,1,3

2,3,1

3,1,2

3,2,1

Not necessarily in that order, but containing all 3! permutations of 1,2,3.

Thanks

The >>perms<< function will do so.

CB