Effacer les filtres
Effacer les filtres

Run a loop every hour regardless of its calculation time!

4 vues (au cours des 30 derniers jours)
Sonima
Sonima le 23 Mar 2019
Commenté : Bruno Luong le 16 Août 2019
Hi All
I want to run a look evey hour and do some math inside the loop.
one solusion is to use tic/toc to get the math time and deduce it from the pause time, but I find it not efficient.
Any solusion to this?
Thanks.
  1 commentaire
Stephen23
Stephen23 le 16 Août 2019
Modifié(e) : Stephen23 le 16 Août 2019
Using tic / toc in a while loop is not very efficient.
Much better to use a timer object.

Connectez-vous pour commenter.

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 23 Mar 2019
Modifié(e) : KALYAN ACHARJYA le 23 Mar 2019
while true
tic
% some math here
elapsedTime=toc
pause(3600+elapsedTime);
clearvars elapsedTime;
end
% Please note on while loop to avoid infinite run
  3 commentaires
Walter Roberson
Walter Roberson le 15 Août 2019
I would expect 3600-elapsedTime not 3600+elapsedTime
Bruno Luong
Bruno Luong le 16 Août 2019
Use timer is much better. I think PAUSE will lock completely 99% of MATLAB.

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 15 Août 2019

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by