MATLAB: How to randomise numbers in a vector

randomvector

Dear all,
Suppose I have this vector x= [1;2;3;4];
How can I randomise it? (i.e. create different combinations of 1, 2, 3 and 4)
Thank you very much in advance, Bianca

Best Answer

See doc randperm:
x = [1;2;3;4]
y = x(randperm(numel(x)))
If this is time-critical, use FEX: Shuffle .