What is the accuracy of the datenum function?
4 次查看(过去 30 天)
显示 更早的评论
What is the accuracy of the datenum function? How many decimal places are retained for the seconds portion of time? When evaluating the elapsed time between dates and times, what decimal place in seconds is it accurate to?
0 个评论
回答(3 个)
Stephen23
2017-2-10
编辑:Stephen23
2017-2-10
Although not clearly documented, in my experience datenum and friends offer repeatable operations down to milliseconds.
Note that the theoretical limit of the double type is just less than a millisecond:
>> (3000*365*24*60*60)/pow2(52)
ans = 2.1007e-005
>> eps(3000*365)*(24*60*60)
ans = 2.0117e-005
0 个评论
Peter Perkins
2017-2-13
Phil, unless you're using pre-R2014b, you are probably better off using datetime instead of datenum. As others have said, the practical limit of datenums is on the order of .1ms. This is one of the many improvements that datetime offers: precision down to nanoseconds.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!