How to present two clusters of dots in parallel and prompt user to decide which side has lesser (or more) by pressing a particular key

Hello!

I’ve managed to create the following experiment:

Presenting a cluster of dots (capped at 9 dots) at a time with the number of dots randomised for each trial and prompting user to decide if the target cluster is less (or more) than a reference number. As a follow up study, I’m interested to design a task such that two clusters of dots can be presented in parallel (with the number of dots for each cluster randomised for each trial but never the same) and user will have to decide which cluster has less (or more) dots as compared to the neighbouring one by pressing a specific key (e.g. left arrow key if the cluster on the left has less, and right arrow key if the cluster on the right has less). May I know how to implement this?


Below is my working code to draw the dots and flip them such that the clusters are presented one at a time and the dots will never overlap with each other:

numberSet = [1:4, 6:9];

for i = 1:nTrialsPerBlock

currentTrialDigit = numberSet(mod(trialorder(i), 8) + 1) % array index 1 - 8, corresponds to 1-4, 6 - 9
        Screen('FillRect', mainwin, bgcolor);
        
        randLocs = Shuffle(1:nrow.*ncolumn);
        for n  =1:currentTrialDigit
            Screen('DrawDots', mainwin, [cellcenter(randLocs(n), 1), cellcenter(randLocs(n), 2)], dotSize, dotColor, [], 1);
        end
        
        Screen('Flip', mainwin);

end