2

我刚刚为 64 位 Mac 安装了新的 MATLAB R2013b,我的操作系统是 OS X 10.8.4。我遇到了 R2013a 从未遇到过的一致问题。当我运行我的一个脚本(见下文)时,整个脚本运行正常,但随后我不断收到一条错误消息“MATLAB 遇到内部问题,需要关闭。” 然后我必须关闭 MATLAB。

我有一种感觉,因为我是 MATLAB 新手,所以我在安装的某个地方搞砸了,但我不确定。

这个完全相同的脚本在我尚未卸载的 R2013a 上仍然可以正常运行。脚本(使用 Psychtoolbox)是一个实验,它打开一个屏幕,呈现一些文本,呈现一个音频文件,并要求参与者以 6 次击键响应。这个脚本只提供两个音频文件,因为我只是在测试它。

所有循环似乎都适用于两个版本的 MATLAB,并且屏幕在最后关闭(仅在 2 次通过主循环后才会发生)。我认为这意味着脚本正在运行,但后期阶段的某些东西会导致问题。

任何和所有的想法都非常感谢!

-乔什

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%  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')   
4

2 回答 2

1

这种错误通常表明发生了剧烈且不可恢复的事情。Psychtoolbox 似乎包含 MEX 文件,这可能是最有可能的罪魁祸首。我要么尝试使用 R2013b 重建那些,要么联系作者以查看他们是否有与 R2013b 兼容的版本。

于 2013-09-18T10:55:55.900 回答
1

这种崩溃可能是由于 OSX 10.8.4 中的一个新错误,导致 PsychToolBox 在关闭与显示服务器的连接时崩溃(并且显然带有 MATLAB)。请参阅此处进行讨论和解决。

任何人仍然有这个问题,请更新到最新版本的 PsychToolBox(这总是一个好主意!)

于 2014-01-05T16:15:38.157 回答