how to set time for script to execute a function

8 views (last 30 days)
I want to execute a function after 10 seconds,how will i wrrite that,,,have to write using timer?

Accepted Answer

Jan on 18 Dec 2012
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)
Walter Roberson
Walter Roberson on 25 Feb 2019
Yes, your yourFunction can ignore the two input parameters (but must have slots for them.)
However if you just want a delay, then use pause()

Sign in to comment.

More Answers (1)

Muruganandham Subramanian
Muruganandham Subramanian on 18 Dec 2012
>> help tic
>> help toc


Find more on Programming Utilities in Help Center and File Exchange


No tags entered yet.

Community Treasure Hunt

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

Start Hunting!