dimanche 20 août 2017

Pairs of random numbers Matlab

I am trying to generate random numbers between 1 and 6 using Matlab's randperm and calling randperm = 6.

Each time this gives me a different array let's say for example:

x = randperm(6)
x = [3 2 4 1 5 6]

I was wondering if it was possible to create pairs of random numbers such that you end up with x like:

x = [3 4 1 2 5 6]

I need the vector to be arranged such that 1 and 2 are always next to each other, 3 and 4 next to each other and 5 and 6 next to each other. As I'm doing something in Psychtoolbox and this order is important.

Is it possible to have "blocks" of random order? I can't figure out how to do it.

Thanks




Aucun commentaire:

Enregistrer un commentaire