0

我正在编写一段实验代码,并被困在这段代码中。

这个想法是显示两个图像,它们下面有文本。参与者必须在这些选项之间进行选择。

我为键盘分配了“z”,为操纵杆分配了“m”。

我的问题是: 1. While 循环有什么问题?2. 有谁知道在图像下创建四个选择框的方法,可以通过鼠标或键盘箭头突出显示?

试验 = 1:16 屏幕('FillRect',mainwin,bgcolor);

% Display keyboard and joystick images
Screen('DrawTexture', mainwin, keyboard, [], leftRect);
Screen('DrawTexture', mainwin, joystick, [], rightRect);
Screen('DrawText',mainwin,['Welcome to the Experiment!'] ,xCenter+150, yCenter+100,textcolor);
Screen('DrawText',mainwin,['Press z to select mental effort or m for physical effort.'] ,xCenter+350, yCenter+500,textcolor);
Screen('Flip', mainwin);
WaitSecs(3);

keyIsDown=0;
while 1
[keyIsDown, secs, keyCode] = KbCheck;
if keyIsDown;
    %checking which keyboard input has been pressed
    if keyCode(Key1);
        Screen('DrawTexture', mainwin, keyboard, [], leftRect);
    elseif keyCode(Key2);
        Screen('DrawTexture', mainwin, joystick, [], rightRect);
        break;
    else keyCode(escKey)
        ShowCursor;
        fclose(outfile);
        Screen('CloseAll');
        return;
    end
end 
end 
 trialorder = Shuffle(1:nTrialsPerGroup); % randomize trial order for each block

结尾

4

0 回答 0