I have created a random array of 32 trials each presenting a stimuli associated with a number 1-4. I want to make a second array also of numbers 1-4 where in 50% of the trials, the value in the second array equals the value in the first array. I also want to make sure that each stimuli (1-4) is being shown roughly the same number of times, i.e. if 16 trials have the same number in each array, 4 of them are stimuli 1, 4 are stimuli 2, 4 are stimuli 3, and 4 are stimuli 4. The other 16 trials do not have the same value in both arrays.
My code for the first array is
array1 = randi([1 4], 1, 32);
I am want array2(ii) == array1(ii) for 50% of the trials.
Thanks!
Best Answer