how to set time for script to execute a function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Arun Badigannavar
il 18 Dic 2012
Commentato: Walter Roberson
il 25 Feb 2019
I want to execute a function after 10 seconds,how will i wrrite that,,,have to write using timer?
0 Commenti
Risposta accettata
Jan
il 18 Dic 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 Commenti
Pranav Mathur
il 25 Feb 2019
Modificato: Pranav Mathur
il 25 Feb 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
il 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()
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!