Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos MATLAB遇到内部错误,需要关闭_Macos_Matlab_Installation_Psychtoolbox - Fatal编程技术网

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

Macos MATLAB遇到内部错误,需要关闭,macos,matlab,installation,psychtoolbox,Macos,Matlab,Installation,Psychtoolbox,我刚刚为64位Mac安装了新的MatlabR2013B,我的操作系统是OSX10.8.4。我遇到了R2013a从未遇到过的问题。当我运行其中一个脚本(见下文)时,整个脚本运行正常,但随后我不断收到错误消息“MATLAB遇到内部问题,需要关闭”。然后我必须关闭MATLAB 我有一种感觉,自从我刚接触MATLAB以来,我在安装方面出了点差错,但我不确定 这个完全相同的脚本在R2013a上仍然运行良好,我还没有卸载它。该脚本(使用Psychtoolbox)是一个实验,它打开一个屏幕,显示一些文本,显示

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

我有一种感觉,自从我刚接触MATLAB以来,我在安装方面出了点差错,但我不确定

这个完全相同的脚本在R2013a上仍然运行良好,我还没有卸载它。该脚本(使用Psychtoolbox)是一个实验,它打开一个屏幕,显示一些文本,显示一个音频文件,并要求参与者用6次击键进行响应。这个脚本只显示两个音频文件,因为我正在测试它

所有的循环似乎在两个版本的MATLAB上都能工作,屏幕在最后关闭(只有2个循环通过主循环后才会关闭)。我认为这意味着脚本正在运行,但后期的某些内容正在引发问题

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

-乔希

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%屏幕和音频设置%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%
%%屏幕%%
%%%%%%%%%%%%
%设置一个漂亮的空白屏幕。
whichScreen=0;
%全屏模式
%窗口=屏幕(其中屏幕为“打开窗口”);
%用于代码测试的小屏幕模式
窗口=屏幕('OpenWindow',0,[450 500],[5,550550]);
白色=白色索引(窗口);%白色的像素值
屏幕(窗口“FillRect”,白色);
屏幕(窗口“翻转”);
%设置显示的全局文本大小。
屏幕(“文本大小”,窗口,15);
屏幕(窗口,'TextFont','Arial');
屏幕('TextStyle',窗口,0)
%%%%%%%%%%%
%%音频%%
%%%%%%%%%%%
%设置初始音频参数:
nR通道=1;%所有的刺激都是单声道的。
频率=44100;
%初始化声音驱动程序。
初始化幻听;
尝试
pahandle=PsychPortAudio(“开放”、“频道[]、[]、[]、频道3、频道、频道);
抓住
%如果上述操作失败,请使用音频设备的标准频率。
psychlasterror(“重置”);%我相信这是对“尝试”中错误的重新设置。
pahandle=PsychPortAudio(“开放的”、[]、[]、3、[]、NR频道);
结束
%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%
%%%%%主回路%%
%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%
home='/Users/josh/Dropbox/Beverlab/Fall_2013_Study/Design/Matlab/'
样本实验={strcat(home,'Stimuli/tokensA/gipa_mono.wav'),。。。
strcat(home,'Stimuli/tokensB/gabo_mono.wav');
时间限制=10;%设定时限。
ans=0;%这用于跟踪参与者是否回答了问题。
numStim=2;%现在就用2来测试代码
李斯特查(0);
对于i=1:numStim;
token=char(样本实验(1,randi([1,2]));%从“SampleExperience”中随机选择一个波形文件,并将其分配给“token”
[y,freq]=wavread(令牌);%读取当前wav文件。
wavedata=y';%转换wav数据。
PsychPortAudio('FillBuffer',pahandle,wavedata);%填满缓冲区,准备开始游戏
t1=PsychPortAudio('Start',pahandle,1,0,1);%播放wave文件并一次性获得时间戳

而GetSecs这种错误通常表明发生了严重的、无法恢复的情况。似乎Psychtoolbox包含MEX文件,这可能是最有可能的罪魁祸首。我会尝试使用R2013b重建这些文件,或者与作者联系,看看他们是否有与R2013b兼容的版本。

此崩溃可能是由于OSX 10.8.4中的一个新错误,导致PsychToolBox在关闭与显示服务器的连接时崩溃(显然是将MATLAB与之一起)。有关讨论和解决方案,请参阅


任何人仍有此问题,请更新至最新版本的PsychToolBox(这始终是一个好主意!)

通过设置断点和单步执行(Windows上为F10,Mac不知道),尝试逐行执行代码要查看是哪一行导致了这种高级关闭MATLAB的方式。如果在脚本之外逐行运行它时没有发生这种情况(可能会发生),请尝试删除代码块,直到运行脚本时错误消失。--此外,如果你能发现并重现错误,但不能解决它,我认为向mathworks报告错误将是下一个合乎逻辑的步骤。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%  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')