Loop with Fixed time

3 ビュー (過去 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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by