필터 지우기
필터 지우기

Run a loop every hour regardless of its calculation time!

조회 수: 12 (최근 30일)
Sonima
Sonima 2019년 3월 23일
댓글: Bruno Luong 2019년 8월 16일
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
Walter Roberson
Walter Roberson 2019년 8월 15일
I would expect 3600-elapsedTime not 3600+elapsedTime
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