Stop the execution with a certain number of second
17 views (last 30 days)
Show older comments
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?
0 Comments
Answers (2)
KSSV
on 22 Mar 2019
t1 = tic ;
while t1
t2 = toc(t1) ;
if t2 > 10
fprintf('loop breaked because 10 seconds passed\n')
break
end
end
2 Comments
KSSV
on 22 Mar 2019
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.
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!