フィルターのクリア

adjusting the time interval of "For" loop

6 ビュー (過去 30 日間)
Fernando Torres
Fernando Torres 2013 年 2 月 19 日
If I make an algorithm using 'for' loop
for examples,
for i=1:10
something
end
it calculates very fast. (as you know)
but,i want to adjust the time interval of each step.
such as
calculate i=1 step, and calculate i=2 step after 10 seconds
is it possible??

採用された回答

Wayne King
Wayne King 2013 年 2 月 19 日
編集済み: Wayne King 2013 年 2 月 19 日
You can put a pause() in the loop
for ii = 1:10
fprintf('Hi\n');
pause(10);
end
I've also seen reports that java's sleep() is more accurate for this, but I can't verify that myself. The java sleep call is in milliseconds.
duration = 10;
for ii = 1:10
fprintf('Hi\n');
java.lang.Thread.sleep(duration*1000);
end
  1 件のコメント
Fernando Torres
Fernando Torres 2013 年 2 月 19 日
Thank you!
it works fine :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by