How to I iterate a random selection among given elements without selecting the same element twice?
Show older comments
Hello,
I am conducting an experiment and would like to present different stimuli (stimpair1 thru stimpair8) across 8 blocks (Nblocks = 8). The presented stimulus within each block shall be the same though. I would like to randomize the stimulus selection without selecting the same stimulus twice, such that a differerent stimulus is presented in every block. I have already randomized stimulus selection using the following code.
stimlist = [list.stimpair1; list.stimpair2; list.stimpair3; list.stimpair4; list.stimpair5; list.stimpair6; list.stimpair7; list.stimpair8];
for bnum = 1:Nblocks
stimpairpresented = [];
stimpairpresented = [stimpairpresented,randi(8)];
switch stimpairpresented
case 1
chosenstim.s1 = list.stimpair1
case 2
chosenstim.s2 = list.stimpair2
case 3
chosenstim.s3 = list.stimpair3
case 4
chosenstim.s4 = list.stimpair4
case 5
chosenstim.s5 = list.stimpair5
case 6
chosenstim.s6 = list.stimpair6
case 7
chosenstim.s7 = list.stimpair7
otherwise
chosenstim.s8 = list.stimpair8;
end
end
Yet, I am stuck at how to implement the condition that the presented stimulus is not the same as one that was presented in the previous blocks. Can someone help me with that?
Thank you for your support in advance.
Best
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!