首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MATLAB遇到内部错误,需要关闭

问MATLAB遇到内部错误,需要关闭
EN

Stack Overflow用户
提问于 2013-09-18 16:27:47
回答 2查看 2.6K关注 0票数 2

我刚刚为64位Mac安装了新的MATLAB R2013b,我的操作系统是OS 10.8.4。我遇到了一个始终如一的问题,这是我在使用R2013a时从未遇到过的。当我运行我的一个脚本(见下文)时,整个脚本运行正常,但随后我一直收到一条错误消息"MATLAB遇到内部问题,需要关闭“。那我就得关掉MATLAB了。

我有一种感觉,因为我是MATLAB的新手,所以我在安装过程中搞砸了,但我不确定。

这个完全相同的脚本仍然可以在R2013a上很好地运行,我还没有卸载它。该脚本(利用心理学工具箱)是一个实验,它打开一个屏幕,呈现一些文本,呈现一个音频文件,并要求参与者通过6次击键来回应。这个脚本只显示两个音频文件,因为我只是在测试它。

所有的循环似乎在两个版本的MATLAB上都可以工作,并且屏幕在结束时关闭(只有在2通过主循环之后才会发生)。我认为这意味着脚本正在工作,但是post阶段的某些东西导致了问题。

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

-Josh

代码语言:javascript
复制
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%  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')   
EN

回答 2

Stack Overflow用户

发布于 2013-09-18 18:55:56

这种类型的错误通常表示发生了一些严重且不可恢复的事情。看起来心理工具箱包含MEX文件,这可能是最有可能的罪魁祸首。我会尝试使用R2013b重新构建它们,或者联系作者,看看他们是否有与R2013b兼容的版本。

票数 1
EN

Stack Overflow用户

发布于 2014-01-06 00:15:38

这种崩溃很可能是由于osx10.8.4中的一个新bug造成的,导致PsychToolBox在关闭与显示服务器的连接时崩溃(显然还带来了MATLAB )。有关讨论和解决方法,请参阅here。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18867316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档