how to set time for script to execute a function

2 vues (au cours des 30 derniers jours)
Arun Badigannavar
Arun Badigannavar le 18 Déc 2012
Commenté : Walter Roberson le 25 Fév 2019
I want to execute a function after 10 seconds,how will i wrrite that,,,have to write using timer?

Réponse acceptée

Jan
Jan le 18 Déc 2012
A timer is the best solution:
TimerH = timer('TimerFcn', @yourFunction, 'StartDelay', 10, ...
'ExecutionMode', 'singleShot');
start(TimerH);
Consider, that the timer function needs two inputs:
function yourFunction(TimerH, EventData)
...
  2 commentaires
Pranav Mathur
Pranav Mathur le 25 Fév 2019
Modifié(e) : Pranav Mathur le 25 Fév 2019
Can we use timer without user input? Like if I just want to wait for 10sec after execution of a part of code before it starts to execute the next part.
Walter Roberson
Walter Roberson le 25 Fév 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()

Connectez-vous pour commenter.

Plus de réponses (1)

Muruganandham Subramanian
Muruganandham Subramanian le 18 Déc 2012
>> help tic
>> help toc

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by