MATLAB: Run a loop every hour regardless of its calculation time!

looptimer

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.

Best Answer

while true
tic
% some math here
elapsedTime=toc
pause(3600+elapsedTime);
clearvars elapsedTime;
end
% Please note on while loop to avoid infinite run