how to set time for script to execute a function

1 visualización (últimos 30 días)
Arun Badigannavar
Arun Badigannavar el 18 de Dic. de 2012
Comentada: Walter Roberson el 25 de Feb. de 2019
I want to execute a function after 10 seconds,how will i wrrite that,,,have to write using timer?

Respuesta aceptada

Jan
Jan el 18 de Dic. de 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 comentarios
Pranav Mathur
Pranav Mathur el 25 de Feb. de 2019
Editada: Pranav Mathur el 25 de Feb. de 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 el 25 de Feb. de 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()

Iniciar sesión para comentar.

Más respuestas (1)

Muruganandham Subramanian
Muruganandham Subramanian el 18 de Dic. de 2012
>> help tic
>> help toc

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by