我刚刚为64位Mac安装了新的MATLAB R2013b,我的操作系统是OS X 10.8.4。我遇到了一个与R2013a从未有过的一致问题。当我运行我的一个脚本(见下文)时,整个脚本都运行正常,但随后我不断收到错误消息“MATLAB遇到了内部问题,需要关闭。”然后我必须关闭MATLAB。
我有一种感觉,因为我是MATLAB的新手,所以我在装置的某个地方蠢蠢欲动,但我不确定。
这个完全相同的脚本在R2013a上运行正常,我还没有卸载。脚本(使用Psychtoolbox)是一个实验,它打开一个屏幕,呈现一些文本,呈现一个音频文件,并要求参与者通过6次击键进行响应。这个脚本只提供两个音频文件,因为我只是测试它。
所有循环似乎都适用于两个版本的MATLAB,屏幕最后关闭(仅在2次通过主循环后才会发生)。我认为这意味着脚本正在运行,但后期阶段的某些事情会导致问题。
非常感谢任何和所有想法!
-Josh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SCREEN & AUDIO SETUP %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%
%% SCREEN %%
%%%%%%%%%%%%
% Set up a nice blank screen.
whichScreen = 0;
% Full Screen mode
%window = Screen(whichScreen, 'OpenWindow');
% Small screen mode used for code testing
window = Screen('OpenWindow',0, [450 450 500], [5,5, 550,550]);
white = WhiteIndex(window); % pixel value for white
Screen(window, 'FillRect', white);
Screen(window, 'Flip');
% Set global text size for the display.
Screen('TextSize', window, 15);
Screen(window,'TextFont','Arial');
Screen('TextStyle', window, 0)
%%%%%%%%%%%
%% AUDIO %%
%%%%%%%%%%%
% Set initial audio parameters:
nrchannels = 1; % All stimuli are mono-sounds.
freq = 44100;
% Initialize sound driver.
InitializePsychSound;
try
pahandle = PsychPortAudio('Open', [], [], 3, freq, nrchannels);
catch
% If the above fails, use the audio device's standard frequency.
psychlasterror('reset'); % I believe this some reseting of the error made in 'try'.
pahandle = PsychPortAudio('Open', [], [], 3, [], nrchannels);
end
%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%
%%%%% MAIN LOOP %%%%%
%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%
home = '/Users/josh/Dropbox/Beverlab/Fall_2013_Study/Design/Matlab/'
SampleExperiment = {strcat(home,'Stimuli/tokensA/gipa_mono.wav'),...
strcat(home,'Stimuli/tokensB/gabo_mono.wav')};
timeLimit = 10; % Set up the time limit.
ans = 0; % This is used to track whether or not the participant answered.
numStim = 2; % Just using 2 right now to test the code
ListenChar(0);
for i=1:numStim;
token = char(SampleExperiment(1,randi([1,2]))); % randomly select a wave file from 'SampleExperiment' and assign it to 'token'
[y,freq] = wavread(token); % Read the current wav file.
wavedata = y'; % Transpose wav data.
PsychPortAudio('FillBuffer', pahandle, wavedata); % fill the buffer, ready to play
t1 = PsychPortAudio('Start', pahandle, 1, 0, 1); % play the wave file and get timestamp in one go
while GetSecs<t1+timeLimit
if ans<6
[secs, keyCode, deltaSecs] = KbWait([],2,t1+timeLimit);
if isempty(find(keyCode,1))
break
end
if ~isempty(find(keyCode,1))
ans=ans+1;
end
end
if ans==6
WaitSecs(rand*3+1);
break
end
end
if ans<6
DrawFormattedText(window, 'Lets try that again...press 6 times', 'center', 'center');
Screen(window, 'Flip');
WaitSecs(1);
Screen(window, 'FillRect', white);
Screen(window, 'Flip');
[y,freq] = wavread(token); % Read the current wav file.
wavedata = y'; % Transpose wav data.
PsychPortAudio('FillBuffer', pahandle, wavedata); % fill the buffer, ready to play
t1 = PsychPortAudio('Start', pahandle, 1, 0, 1); % play the wave file and get timestamp in one go
while GetSecs<t1+timeLimit
if ans<6
[secs, keyCode, deltaSecs] = KbWait([],2,t1+timeLimit);
if isempty(find(keyCode,1))
break
end
if ~isempty(find(keyCode,1))
ans=ans+1;
end
end
if ans==6
WaitSecs(rand*3+1);
break
end
end
end
end
Screen('CloseAll')
答案 0 :(得分:1)
这种错误通常表明发生了严重且不可恢复的事情。 Psychtoolbox似乎包含MEX文件,这可能是最可能的罪魁祸首。我会尝试使用R2013b重建那些,或者联系作者,看看他们是否有与R2013b兼容的版本。
答案 1 :(得分:1)
这次崩溃可能是由于OSX 10.8.4中的一个新错误造成的,导致PsychToolBox在关闭与显示服务器的连接时崩溃(并且显然带有MATLAB)。有关讨论和解决,请参阅here。
任何人仍有这个问题,请更新到最新版本的PsychToolBox(这总是一个好主意!)