generate timestamp in millisecond interval for interpolation

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.

 採用された回答

Walter Roberson
Walter Roberson 2013 年 2 月 19 日

1 投票

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 件のコメント

Erni
Erni 2013 年 2 月 19 日
thanks. Just to make me clearer. Since the milliseconds is fraction of second in datenum, then none will be able to generate datenum with an exact milliseconds interval?
Jan
Jan 2013 年 2 月 19 日
@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 2013 年 2 月 19 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by