필터 지우기
필터 지우기

Or any other key...

조회 수: 5 (최근 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