generate timestamp in millisecond interval for interpolation

3 views (last 30 days)
how to generate timestamp 0.250 seconds (4Hz) sampling interval? I tried [firstdatenum:0.125/86400:enddatenum]', but it gave me four different intervals (using diff) in the order 10^-6 (it is very small indeed, but annoying). I need the timestamp to interpolate it with other timeframe with 8Hz sampling interval.
If anyone can help. Thanks.

Accepted Answer

Walter Roberson
Walter Roberson on 19 Feb 2013
You are not going to be able to get exactly 0.25 second intervals in time stamps, as 86400 is not an exact divisor of 1.
  3 Comments
Jan
Jan on 19 Feb 2013
@Erni: Yes, the double values replied by datenum cannot contain the milliseconds exactly due to the limited precision. The absolute value of the serial datenumbers deviate by -6.605e-011 and 5.036e-011 in my tests. This meets the possible resolution for doubles, when you consider the 6 leading digits.
The datevec format offers a higher resolution.
Walter Roberson
Walter Roberson on 19 Feb 2013
If the world happened to use a time scheme in which days were a power-of-two units long, and you were working with "mibiseconds" (1/1024 of the modified seconds), then you would be able to store them exactly.
The difficulty is not with "fractions of a second", the difficulty is that the fractions (of a day) do not have exact finite binary representations, just the same way that 1/3 does not have an exact finite decimal representation.

Sign in to comment.

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!