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

4 ビュー (過去 30 日間)
Yash Jain
Yash Jain 2019 年 2 月 2 日
回答済み: Ege Keskin 2019 年 2 月 3 日
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.

回答 (1 件)

Ege Keskin
Ege Keskin 2019 年 2 月 3 日
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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by