- Schedule Command Execution Using Timer.
- Timer limitations which notes "Avoid using timer objects for real-time applications."
- To get clock time: clock
How do I start a function at the exact computer clock time?
3 次查看(过去 30 天)
显示 更早的评论
t1=datetime('now');
tstart=('16-Nov-2021 11:20:00')
0 个评论
采纳的回答
Adam Danz
2021-11-15
编辑:Adam Danz
2021-11-17
> How do I start a function at the exact computer clock time?
It depends on how you define "exact" and "start".
If "start" means to evoke the function and if "exact" allows for several ms lag, you could use a timer to continually check the clock time at regular intervals and evoke the function as soon as the specified time is detected.
The minimum interval is 0.001 sec (1 ms) but you should expected small delays associated with runtime of the timer and other internal processing required to call your function. If Matlab is busy processing another task when the target clock time arrives, there could be additional delays.
Also see
2 个评论
Adam Danz
2021-11-15
Sam Demidenko's answer moved here as a comment
> Yes, evoke a function and 100mS is acceptable.
> Not sure how to create a wait loop, such that the programed time is not missed.
> Thank you
Adam Danz
2021-11-15
That's all done within the timer function.
Timers are a little confusing to set up if you haven't set one up before. I recommend going through the timer documentation and examples to start. Once you have a timer put together, if you still have questions, share the timer and I can help fill in the gaps.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Clocks and Timers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!