MATLAB Answers

How to exit a while true loop after some time has elapsed

11 views (last 30 days)
Yash Jain
Yash Jain on 2 Feb 2019
Answered: Ege Keskin on 3 Feb 2019
I created a while true loop to continuously check for user input using ginput. I want the program to end automatically if the user doesn't click anywhere for 10 seconds. I can't seem to figure out how to do so. Please help.

  0 Comments

Sign in to comment.

Answers (1)

Ege Keskin
Ege Keskin on 3 Feb 2019
You can use something like;
while
%%YOUR CODE HERE
if
%no input from the user for 10 seconds (figure out how to code this.)
break; %if the above condition is satisified, the loop will terminate.
end
%%YOUR CODE HERE
end %end of the while loop

  0 Comments

Sign in to comment.

Sign in to answer this question.