MATLAB: Constructing for loop in terms of seconds for looptimer 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 Best 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 Related SolutionsMATLAB: Can you make matlab do a beep every 5 seconds This is a job for the timer:TimerH = timer('Period', 5, 'ExecutionMode', 'fixedRate', ... 'Callback', @TimerCallback);start(TimerH);function TimerCallback(TimerH, EventData)beep; MATLAB: Seconds from the clock function c = clock; seconds = c(6) Related QuestionTime dependent programsConstruct Timer using evalinAverage of termsBreaking out from loop
Best Answer