how to set time for script to execute a function

2 Ansichten (letzte 30 Tage)
Arun Badigannavar
Arun Badigannavar am 18 Dez. 2012
Kommentiert: Walter Roberson am 25 Feb. 2019
I want to execute a function after 10 seconds,how will i wrrite that,,,have to write using timer?

Akzeptierte Antwort

Jan
Jan am 18 Dez. 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 Kommentare
Pranav Mathur
Pranav Mathur am 25 Feb. 2019
Bearbeitet: Pranav Mathur am 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
Walter Roberson am 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()

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Muruganandham Subramanian
Muruganandham Subramanian am 18 Dez. 2012
>> help tic
>> help toc

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by