7

我在 Macbook 计算机的 Windows XP 分区中的 MATLAB R2011B 中运行 psychtoolbox-3.0.10。我一直在尝试为行为科学课程运行一个 Matlab 脚本(请参见此处。该文件名为FunkyScreen.m.

它工作了前 30 秒(前 80 行左右),然后 Matlab 突然崩溃并关闭。我单击了消息的“详细信息”按钮,它显示程序可能由于mex文件而停止。

问题:

  • 我应该手动设置 Matlab 来编译这些文件吗?
  • 还是只是因为内部问题而崩溃?

脚本是:

% FunkyScreen.m
%
% opens a window using psychtoolbox,
% makes the window do some funky things
%
% written for Psychtoolbox 3 on the PC by IF 3/2007
screenNum=0;
flipSpd=13;% a flip every 13 frames
[wPtr,rect]=Screen('OpenWindow',screenNum);
monitorFlipInterval=Screen('GetFlipInterval', wPtr); 
% 1/monitorFlipInterval is the frame rate of the monitor
black=BlackIndex(wPtr);
white=WhiteIndex(wPtr);
% blank the Screen and wait a second
Screen('FillRect',wPtr,black);
Screen(wPtr,'Flip');
HideCursor;
tic
while toc<1;
end
% make a rectangle in the middle of the screen flip colors and size
Screen('FillRect',wPtr,black);
vbl=Screen(wPtr,'Flip');% collect the time for the first flip with vbl
for i=1:10
Screen('FillRect',wPtr,[0 0 255], [100 150 200 250]);
vbl=Screen(wPtr, 'Flip', vbl+(flipSpd*monitorFlipInterval));
% flip 13 frames after vbl
Screen('FillRect',wPtr,[255 0 0], [100 150 400 450]);
vbl=Screen(wPtr, 'Flip', vbl+(flipSpd*monitorFlipInterval));
end
% blank the screen and wait a second
Screen('FillRect',wPtr,black);
vbl=Screen(wPtr,'Flip', vbl+(flipSpd*monitorFlipInterval));
tic
while toc<1;
end
% make circles flip colors & size
Screen('FillRect',wPtr,black);
vbl=Screen(wPtr,'Flip');
for i=1:10
Screen('FillOval',wPtr,[0 180 255], [ 500 500 600 600]);
vbl=Screen(wPtr, 'Flip', vbl+(flipSpd*monitorFlipInterval));
Screen('FillOval',wPtr,[0 255 0], [ 400 400 900 700]);
vbl=Screen(wPtr, 'Flip', vbl+(flipSpd*monitorFlipInterval));
end
% blank the Screen and wait a second
Screen('FillRect',wPtr,black);
vbl=Screen(wPtr,'Flip', vbl+(flipSpd*monitorFlipInterval));
tic
while toc<1;
end
% make lines that flip colors size & position
Screen('FillRect',wPtr,black);
vbl=Screen(wPtr,'Flip');
for i=1:10
Screen('DrawLine',wPtr,[0 255 255], 500, 200, 700 ,600, 5);
vbl=Screen(wPtr, 'Flip', vbl+(flipSpd*monitorFlipInterval));
Screen('DrawLine',wPtr,[255 255 0], 100, 600, 600 ,100, 5);
vbl=Screen(wPtr, 'Flip', vbl+(flipSpd*monitorFlipInterval));
end
% blank the Screen and wait a second
Screen('FillRect',wPtr,black);
vbl=Screen(wPtr,'Flip', vbl+(flipSpd*monitorFlipInterval));
tic
while toc<1;
end
% combine the stimuli
Screen('FillRect',wPtr,black);
vbl=Screen(wPtr,'Flip');
for i=1:10
Screen('FillRect',wPtr,[0 0 255], [100 150 200 250]);
Screen('DrawLine',wPtr,[0 255 255], 500, 200, 700 ,600, 5);
Screen('FillOval',wPtr,[0 180 255], [ 500 500 600 600]);
Screen('TextSize', wPtr , 150);
Screen('DrawText', wPtr, 'FUNKY!!', 200, 20, [255 50 255]);
vbl=Screen(wPtr, 'Flip', vbl+(flipSpd*monitorFlipInterval));
Screen('FillRect',wPtr,[255 0 0], [100 150 400 450]);
Screen('FillOval',wPtr,[0 255 0], [ 400 400 900 700]);
Screen('DrawLine',wPtr,[255 255 0], 100, 600, 600 ,100, 5);
vbl=Screen(wPtr, 'Flip', vbl+(flipSpd*monitorFlipInterval));
end
% blank the screen and wait a second
Screen('FillRect',wPtr,black);
vbl=Screen(wPtr,'Flip', vbl+(flipSpd*monitorFlipInterval));
tic
while toc<1;
end
Screen('CloseAll');
ShowCursor
4

1 回答 1

1

这是您可以(可能)消除问题的方法。

Step 1: Run the code, try to get an indication of where it crashes
Step 2: Possibly using the information from Step 1, devide your code in 2 halves.
Step 3: Run both halves separately, see which one crashes
Step 4: Keep repeating the steps above untill you have identified the culprit 
Step 5: Try to deal with the specific problem that is found
于 2012-11-16T22:37:27.080 回答