How to keep stimulus on screen for certain length of time

I am using Psychtoolbox on MATLAB R2020a on Mac OS. I am trying to get the fixation cross to stay on the screen for 10 seconds before displaying the next stimulus. I have tried WaitSec() but this did not work.

% Experimental instructions
line1 = 'Choose the sequence with the highest mean';
line2 = '\n Press any key when you are ready to begin';

% Draw all the text in one go
Screen('TextSize', window, 40);
Screen('TextFont', window, 'Ariel');
DrawFormattedText(window, [line1 line2],...
    'center', 'center', white);
Screen('Flip', window);
KbStrokeWait;

% Fixation cross
Screen('DrawLines', window, allCoords,lineWidthPix, white, [xCenter yCenter], 2);

% trial 1
DrawFormattedText(window, sprintf(seq1), rightX, rightY, [0 1 0]);
DrawFormattedText(window, sprintf(seq2), leftX, leftY, [1 0 1]);
DrawFormattedText(window, sprintf(seq3), upX, upY, [1 1 0]);

Use the when argument to Screen(‘Flip’) for precisely timing when things are shown, such as the next thing after your fixation cross.

Thanks. Could you please explain how to construct the when argument? I tried:

when(Screen('DrawLines', window, allCoords,lineWidthPix, white, [xCenter yCenter], 2), WaitSecs(10));

But that did not work.

Read “Screen Flip?”, Thats how you get help for the PTB functions. One of the inputs is when. See some of Peter Scarfe’s ptb demos as a start, they’ll tell you about basic use and how to do proper timing