lundi 30 novembre 2015

MatLAB help: shuffling a predefined vector without consecutive numbers

I'm having troubles with randomly a shuffling vector but without consecutive numbers, given that each value is repeated equally.

More specifically, I would like to repeat the matrix [1:4] ten times (40 elements in total) so that 1, 2, 3 and 4 would all repeat 10 times without being consecutive.

If there is any clarification needed please let me know, I hope this question was clear.

This is what I have so far:

cond_order = repmat([1:4],10,1); %make matrix
cond_order = cond_order(:); %make sequence

I know randperm is quite relevant but I'm not sure how to use it with the one condition of non-consecutive numbers.




Aucun commentaire:

Enregistrer un commentaire