"Matlab Shuffle Array" To shuffle a: a(randperm(length(a))) Example: a = [10 2 5 20]; a = a(randperm(length(a))) a = 5 10 2 20 Source.