Run a loop every hour regardless of its calculation time!

12 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2019-8-16
编辑:Stephen23 2019-8-16
Using tic / toc in a while loop is not very efficient.
Much better to use a timer object.

请先登录,再进行评论。

采纳的回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019-3-23
编辑:KALYAN ACHARJYA 2019-3-23
while true
tic
% some math here
elapsedTime=toc
pause(3600+elapsedTime);
clearvars elapsedTime;
end
% Please note on while loop to avoid infinite run
  3 个评论
Bruno Luong
Bruno Luong 2019-8-16
Use timer is much better. I think PAUSE will lock completely 99% of MATLAB.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2019-8-15

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by