MATLAB Answers

how to set time for script to execute a function

Asked by Arun Badigannavar on 18 Dec 2012

I want to execute a function after 10 seconds,how will i wrrite that,,,have to write using timer?



No products are associated with this question.

2 Answers

Answer by Jan Simon
on 18 Dec 2012
 Accepted answer

A timer is the best solution:

TimerH = timer('TimerFcn', @yourFunction, 'StartDelay', 10, ...
               'ExecutionMode', 'singleShot');

Consider, that the timer function needs two inputs:

function yourFunction(TimerH, EventData)


Answer by Muruganandham Subramanian on 18 Dec 2012

>> help tic

>> help toc


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today