how to set time for script to execute a function

1 次查看(过去 30 天)
I want to execute a function after 10 seconds,how will i wrrite that,,,have to write using timer?

采纳的回答

Jan
Jan 2012-12-18
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 个评论
Pranav Mathur
Pranav Mathur 2019-2-25
编辑:Pranav Mathur 2019-2-25
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 2019-2-25
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()

请先登录,再进行评论。

更多回答(1 个)

Muruganandham Subramanian
>> help tic
>> help toc

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by