Or any other key...

2 次查看(过去 30 天)
Brett
Brett 2012-11-30
This is my code:
[keyIsDown,secs,keyCode, deltaSecs] = KbCheck
while keyIsDown == 0; %Will present this screen until a key is pressed
[keyIsDown, secs, keyCode, deltaSecs] = KbCheck;
%RT = GetSecs - starttrial - time;
if q1tri == 1 && q1col == 1 && keyCode(1,98) == 1 %down
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
WaitSecs(tar);
elseif q1tri == 2 && q1col == 1 && keyCode(1,104) == 1 %up
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
WaitSecs(tar);
elseif q1tri == 3 && q1col == 1 && keyCode(1,100) == 1; %left
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
WaitSecs(tar);
elseif q1tri == 4 && q1col == 1 && keyCode(1,102) == 1; %right
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
WaitSecs(tar);
end
What this says is that when a target color is present, and the keyboard arrow key matches the arrow displayed it produces a black screen for a particular amount of time. What I need is code that says something like if any other key is pressed (including the arrow keys that don't match), it produces a black screen for a different amount of time. I tried using pause and input commands, but they didn't seem to work. :(
any help, would be super appreciated, Brett
  2 个评论
Brett
Brett 2012-11-30
I ended up grunting it out, but I'm still curious if anyone knows a really easy way to do this. :)
Jan
Jan 2012-11-30
I do not understand the question. I do neither know the function KbCheck(), not the values of the variables q1col, q1tri and tar. What is "the arraow displayed"? Is the replied keyCode really a vector?

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2012-11-30
编辑:Jan 2012-11-30
I try to guess:
Screen('FillRect',window,[0 0 0])
Screen('Flip',window)
keyIndex = find(keyCode(1, [98, 104, 100, 102])); % ???
if q1col && length(keyIndex) == 1 && (q1tri == keyIndex)
WaitSecs(tar);
else
WaitSecs(theOtherTar);
end

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by