A set of 20 numbers is stored inside the vector d , for example:
d = [ 5 6 7 8 9 ....]
I use
i = randperm(length(d)); d = d(i);
to randomly shuffle the numbers inside the matrix.
However, I need to find a way to limit shuffling so that the number does not move more than "5" from the starting position?
The value, if initially d(2) = 6 final position 6 should move only by d(1) to d(2+5) .
Note d(1) , because the numbers cannot go into a negative position.
Any help on this would be appreciated! Also, if there is a more efficient way with shuffling, please kindly inform me!
source share