Loop with Fixed time

조회 수: 14 (최근 30일)
Jen-Yu Hsiao
Jen-Yu Hsiao 2013년 2월 3일
How can I make the loop with fixed time?
For example:
for i=1:5
 somecode;
end
I want to make every calculation time of the loop is about 1 sec And the total calculation time is about 5 sec

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 3일
for i=1:5
%somecode;
pause(1-tw) % tw is your computing time
end
%to find your computing time use tic and toc
  댓글 수: 2
Jen-Yu Hsiao
Jen-Yu Hsiao 2013년 3월 5일
TKS~!!
Jan
Jan 2013년 3월 5일
편집: Jan 2013년 3월 5일
The Java sleep() timer is more accurate: see http://undocumentedmatlab.com/blog/pause-for-the-better/. A timer might be even more precise.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Clocks and Timers에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by