I'm a very beginner of Matlab and I'm struggling in randomizing trials in my task on Psychtoolbox, in Matlab. My trials consist in 5 verbal stimuli repeated 12 times (in total 60 trials). I have 2 practice trials and then the 60 testing trials. What I would like to do is to present the practice trial in a fixed order, and the testing trials in a random order, without having the same verbal stimulus repeated consecutively.
My stimulus file (stim.txt) has a column "items" with the stimuli that looks like:
practice1
practice 2
word1
word2
word3
word4
word5
word1
word2
word3
word4
word5
.... x other 11 times (only the testing stimuli are repeated) ....
Here is the part of interest of my code:
%here I define the trial info
trial = 1;
maxTrial = length(stim.items); %this is the excel file from which I take the stimuli
% I define the number of practice trials
NumOfPracticeTrials=2;
%I randomize only the testing trials
TrialIndex(NumOfPracticeTrials+1:maxTrial)=NumOfPracticeTrials+randperm((maxTrial-NumOfPracticeTrials);
This code works, so that I present the practice trials in a fixed order, while the testing trials are randomized. However, when I run the experiment, some testing verbal stimuli are repeated twice or even more times consecutively.
I want to randomize the testing trials without having the same verbal stimulus repeated consecutively.
Can I ask for your help? Thank you very very much!! :)