Constructing for loop in terms of seconds

12 Ansichten (letzte 30 Tage)
Yigit
Yigit am 20 Nov. 2011
Kommentiert: vcmorini am 22 Apr. 2017
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

Akzeptierte Antwort

Jan
Jan am 20 Nov. 2011
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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by