MATLAB: How to generate an unsorted permutation of integers in MATLAB 7.7 (R2008b)

ascendingdescendingMATLABpermuterepeatrepeatedshufflesortsortedunique

I would like to generate numbers, say, from 1 to 10. However, I would like to shuffle these numbers so that they are not in any sorted order.

Best Answer

This enhancement has been incorporated in Release 2009b (R2009b). For previous product releases, read below for any possible workarounds:
The RANDPERM function can be used to generate a random permutation of integers. For example, the following statement creates a random permutation of integers from 1 to 10:
randperm(10)
Related Question