Solutions ordered in terms of both how much work they are and how
recommended they are:
Use GetSecs not the matlab time functions, the latter may have
pretty low resolution depending on clock hardware
move to using KbQueues (see KbQueueDemo), along with using
Screen(‘Flip’)'s when parameter for presentation timing, as
recommended in the PTBTutorial-ECVP2013.pdf in the PsychDocumentation
folder
If you don’t use the timestamps and target times of the Screen('Flip') command, e.g., t0 = Screen('Flip', window) then your t0 may have no relationship to true stimulus presentation time at all, there could be arbitrary errors. We have many demos and help in the cited PDF file on how to do timing right, instead of fooling oneself or suffering from way less precision than possible.