# timing question

**URL:** <https://psychtoolbox.discourse.group/t/timing-question/1875>\
**Category:** Uncategorized\
**Created:** [October 18, 2017, 2:38pm UTC](https://psychtoolbox.discourse.group/t/timing-question/1875 "2017-10-18T14:38:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkoutromanoy](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@mkoutromanoy](https://psychtoolbox.discourse.group/u/mkoutromanoy)\
**Post date:** [October 18, 2017, 2:38pm UTC](https://psychtoolbox.discourse.group/t/timing-question/1875/1 "2017-10-18T14:38:22Z")

</div>

Hello! I am very new with psychtoolbox so I have an important question about timing. In the simple script below i am trying to make the word " FEEDBACK" appear on my screen for a certain amount of time. I've done this based on a demo i found online but I don't know for how long the word appears on screen. How can I make the presentation last for ...le'ts say 4 secs and display the presentation duration on my command line?&nbsp;

Thank you!

% Clear the workspace and the screen

close all;

clearvars;

sca

Screen('Preference', 'SkipSyncTests', 1);

% Here we call some default settings for setting up Psychtoolbox

PsychDefaultSetup(2);

% Get the screen numbers

screens = Screen('Screens');

% Select the external screen if it is present, else revert to the native

% screen

screenNumber = max(screens);

% Define black, white and grey

black = BlackIndex(screenNumber);

white = WhiteIndex(screenNumber);

grey = white / 2;

% Open an on screen window and color it grey

[window, windowRect] = PsychImaging('OpenWindow', screenNumber, grey);

% Set the blend funciton for the screen

Screen('BlendFunction', window, 'GL\_SRC\_ALPHA', 'GL\_ONE\_MINUS\_SRC\_ALPHA');

% Get the size of the on screen window in pixels

% For help see: Screen WindowSize?

[screenXpixels, screenYpixels] = Screen('WindowSize', window);

% Get the centre coordinate of the window in pixels

% For help see: help RectCenter

[xCenter, yCenter] = RectCenter(windowRect);

% Retreive the maximum priority number

topPriorityLevel = MaxPriority(window);&nbsp; %to window ths line 22

Priority(topPriorityLevel);

vbl = Screen('Flip', window);% to window ths line 22

% Query the frame duration

ifi = Screen('GetFlipInterval', window);

numSecs = 1;

numFrames = round(numSecs / ifi);

waitframes = 1;

for frame = 1:numFrames

&nbsp; &nbsp; % Draw text in the upper portion of the screen with the default font in red

&nbsp; &nbsp; Screen('TextSize', window, 70);

&nbsp; &nbsp; DrawFormattedText(window, 'FEEDBACK', 'center',...

&nbsp; &nbsp; &nbsp; &nbsp; screenYpixels \* 0.25, [1 0 0]);

&nbsp; &nbsp; % Flip to the screen

&nbsp; &nbsp; vbl = Screen('Flip', window, vbl + (waitframes - 0.5) \* ifi);&nbsp; %deixnei 'feedback' gia periorismeno xroniko diasthma

&nbsp; &nbsp;&nbsp;

end

Priority(0);

sca;
