這次的PTB實驗我幾乎每一個代碼塊都寫了註釋,應該比較容易看懂
function ret=imageInstruct(wptr,prefix,postfix,fs)
imgs.('img') = imread([prefix '.' postfix]);
wrect = Screen('Rect',wptr);
Screen('PutImage',wptr,imgs.img); %展示圖片
Screen('Flip',wptr);
spaceKey = KbName('space'); %定義按鍵
ListenChar(2); %把按鍵鎖定在實驗中
while true
[~,~,keycode]=KbCheck;
if keycode(spaceKey)
break; %等待按空格鍵
end
end
KbWait;
ListenChar(0); %釋放按鍵
clear imgs;
ret=0;
end
接下來我會貼出好幾個功能模塊,可以按需使用。