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

 Accepted Answer

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

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 20 Nov 2011

Commented:

on 22 Apr 2017

Community Treasure Hunt

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

Start Hunting!