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 tags are associated with this question.


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


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!