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

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?
@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.
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 Exchange에서 Dates and Time에 대해 자세히 알아보기

질문:

2013년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by