MATLAB: How can i redistribute randomly the numbers in a matrix

random redistribution

I have a matrix with certain numbers, i would like to redistribute randomly these numbers. I want to underline that i don't want to distribute random numbers, but to REdistribute the numbers contained in the matrix, and to redistribute them randomly. Thank you in advance for your help

Best Answer

Use randperm, something like
randomLocations = randperm(numel(yourArray))
newArray = yourArray(randomLocations) % A 1-D list at this point
newArray = reshape(newArray, size(yourArray)) % Now the same shape as original.
Related Question