Hello everybody, I have a problem with this following issue:
I generated some sounds in left or right ear randomly and participants should push the left or right button on mouse (it means if a sound has been presented in the left ear, left button should been pushed ). My problem is this: participants have just3 seconds for clicking and after that the script should continue. (I have 2 ways: one way if I use GetClicks in psychtoolbox it will pause (it should not be paused) and second way if I use GetMouse in psychtoolbox I can not define right or left button).
Please if anyone have any ideas tell me about that I really need it. Thanks in advance.
- First way: using from GetClicks causes pause
clc
clear;
SamplingRate=48000;
F=[250 500 1000 2000 4000];
t=linspace(0,1,SamplingRate);
ind=0;
memory{1,1}={0};
for i=1:length(F)
ind=1+ind;
Frequency = F(i);
y=sin(t*2*pi*Frequency);
sound(y,SamplingRate) ;
%% This here I want to wait 3 second for clicking, after that the script continues but it will stope by using GetClicks
[clicks,~,~,whichButton] = GetClicks; %% This function is related to the Psychtoolbox in Matlab
%%
pause(5)
memory{1,ind} = y';
end
- Second way: using GetMouse is good but I can not define right or left button in this code
clc
clear;
SamplingRate=48000;
wait4resTime = 3;
F=[250 500 1000 2000 4000];
t=linspace(0,1,SamplingRate);
ind=0;
memory{1,1}={0};
Z=[];
for i=1:length(F)
ind=1+ind;
Frequency = F(i);
y=sin(t*2*pi*Frequency);
tStart=GetSecs;
sound(y,SamplingRate) ;
%% This here I want to wait 3 second for clicking, after that the script continues but I can not define the right or left button
MousePress=0; %initializes flag to indicate no response
while (MousePress==0 && ( (GetSecs-tStart) < wait4resTime-.1 ))
[x,y,buttons]=GetMouse(); %waits for a key-press
MousePress=any(buttons); %% I have problem and I can not define right or left button this here.
Z(1,jnd)=MousePress;
end
elapsedTime = GetSecs-tStart;
%%
pause(4)
memory{1,ind} = y';
end