how to set time for script to execute a function
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to execute a function after 10 seconds,how will i wrrite that,,,have to write using timer?
댓글 수: 0
채택된 답변
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
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
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!