Constructing for loop in terms of seconds

Hi,
for(10 seconds){
do this }
I would like to construct the following but I couldn't figure out how to input loop parameter in terms of time.
Thanks

 採用された回答

Jan
Jan 2011 年 11 月 20 日

7 投票

It does not work with a FOR loop, but with WHILE:
t0 = clock;
while etime(clock, t0) < 10
pause(0.05); % Some dummy lines
disp(clock);
end

1 件のコメント

vcmorini
vcmorini 2017 年 4 月 22 日
Very nice answer! Thanks!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2011 年 11 月 20 日

コメント済み:

2017 年 4 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by