Depends on how you are taking input from the user. Here are a couple ideas:
(1) tic toc
Use "tic" to start the timer just before you give the user the question. After the person has answered the question, you can add something like this:
tElapsed=toc;
if tElapsed>tmax
display('You took too long to answer.')
end
(2) uicontrol
I don't know the details of this (just looked through the help for a bit), but you can use uiwait(f,TL) to wait until figure f is closed of TL seconds has elapsed. So maybe you could do something like this?
ans=0;
f=figure;
h=uicontrol('String','Test');
uiwait(f,10);
close(f)
if ans==0
display('You took too long')
end
Best Answer