Azzera filtri
Azzera filtri

What is the accuracy of the datenum function?

4 visualizzazioni (ultimi 30 giorni)
Phil
Phil il 10 Feb 2017
Risposto: Peter Perkins il 13 Feb 2017
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?

Risposte (3)

Andreas
Andreas il 10 Feb 2017
Milliseconds

Stephen23
Stephen23 il 10 Feb 2017
Modificato: Stephen23 il 10 Feb 2017
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

Peter Perkins
Peter Perkins il 13 Feb 2017
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.

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by