Run a loop every hour regardless of its calculation time!

9 views (last 30 days)
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 Comment
Stephen23
Stephen23 on 16 Aug 2019
Edited: Stephen23 on 16 Aug 2019
Using tic / toc in a while loop is not very efficient.
Much better to use a timer object.

Sign in to comment.

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 23 Mar 2019
Edited: KALYAN ACHARJYA on 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 Comments
Bruno Luong
Bruno Luong on 16 Aug 2019
Use timer is much better. I think PAUSE will lock completely 99% of MATLAB.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 15 Aug 2019

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!