Stop the execution with a certain number of second

조회 수: 17 (최근 30일)
J.J
J.J 2019년 3월 22일
답변: J.J 2019년 3월 22일
I want to stop the execution with a certain number of seconds. In toher words, the script is running, but when the length is greater than 100 seconds, I want to stop the execution.
How I must do it?

답변 (2개)

KSSV
KSSV 2019년 3월 22일
t1 = tic ;
while t1
t2 = toc(t1) ;
if t2 > 10
fprintf('loop breaked because 10 seconds passed\n')
break
end
end
  댓글 수: 2
KSSV
KSSV 2019년 3월 22일
J.J commented: But I want to leave the script, not to stop during 10 seconds. So, I want that the script runs but when the legnth is x seconds, I want leave it.
KSSV
KSSV 2019년 3월 22일
break does the same right? It comes out of loop/ code.

댓글을 달려면 로그인하십시오.


J.J
J.J 2019년 3월 22일
yes, but I tried to do it, and only it stops during the length established,later it continues running the code.
And i don't know why is it.
Do you know why it will happen?

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by