【发布时间】:2021-10-13 13:42:31
【问题描述】:
我对以下问题有疑问: 我在左耳或右耳随机产生了一些声音,参与者应按下鼠标上的左键或右键(这意味着如果左耳出现声音,则应按下左键)。 我的问题是这样的:参与者只有 3 秒钟的点击时间,然后脚本应该继续。 (我有两种方法:一种方法如果我在 psychtoolbox 中使用 GetClicks 它将暂停(不应该暂停),第二种方法如果我在 psychtoolbox 中使用 GetMouse 我无法定义 左右按钮)。 如果有人有任何想法,请告诉我我真的需要它。提前致谢。
%% 1) 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
%% 2. 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
【问题讨论】:
标签: psychtoolbox