Constructing for loop in terms of seconds

47 vues (au cours des 30 derniers jours)
Yigit
Yigit le 20 Nov 2011
Commenté : vcmorini le 22 Avr 2017
Hi,
for(10 seconds){
do this }
I would like to construct the following but I couldn't figure out how to input loop parameter in terms of time.
Thanks

Réponse acceptée

Jan
Jan le 20 Nov 2011
It does not work with a FOR loop, but with WHILE:
t0 = clock;
while etime(clock, t0) < 10
pause(0.05); % Some dummy lines
disp(clock);
end
  1 commentaire
vcmorini
vcmorini le 22 Avr 2017
Very nice answer! Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by