MATLAB: How to sort a vector in a random manner in MATLAB MATLABrandomsort I have a 1-dimensional array and would like to sort the elements of this vector randomly. Best Answer To sort the elements of a vector randomly you can use the RANDPERM() function.RANDPERM(n) returns a random permutation of the integers 1:n.a = [1 2 3 4 5];a_rand = a(randperm(length(a))); Related SolutionsMATLAB: Generating random numbers in order If a and b are the lower and upper limits you have in mind for the numbers, do this: x = sort((b-a)*rand(n,1)+a,'ascend' or 'descend'); MATLAB: Clustering of rows in random manner Have a look on randsample and randperm. Related QuestionRandom order, but equally appearanceSplitt a matrix in specified mannerHow to generate an unsorted permutation of integers in MATLAB 7.7 (R2008b)Random save two large matrices in the same mannerRandom numbers
Best Answer