我在MacBook电脑的Windows XP分区中运行MATLAB R2011B中的psychtoolbox-3.0.10。我一直在尝试使用Matlab运行脚本来进行行为科学课程(参见here。该文件名为FunkyScreen.m
。
它工作前30秒(前80行左右)然后Matlab突然崩溃并关闭。我点击了消息的“详细信息”按钮,它显示程序可能因mex
文件而停止。
% 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
答案 0 :(得分: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