开发者

MATLAB date format

I'm trying to convert date string to date number using dtstr2dtnummx (three time faster than datenum), but for this input

dtstr2dtnummx({'2010-12-12 12:21:13.101'},'yyyy-mm-dd HH:MM:SS.FFF')

and this input

dtstr2dtnummx({'2010-12-12 12:21:13.121'},'yyyy-mm-dd HH:MM:SS.FFF')

getting the same output. I used the 开发者_Python百科following tutorial to build up the date format.

Ahh sorry, UPDATED


The corresponding format of 'FFF' in datenum is 'SSS' in dtstr2dtnummx, as can be seen in cnv2icudf.m line #126. The end result is:

>> d1 = dtstr2dtnummx({'2010-12-12 12:21:13.101'},'yyyy-MM-dd HH:mm:ss.SSS')
d1 =
      734484.514734965

>> d2 = dtstr2dtnummx({'2010-12-12 12:21:13.121'},'yyyy-MM-dd HH:mm:ss.SSS')
d2 =
      734484.514735197

>> % double check the results - difference should equal 0.02 secs:
>> secsPerDay = 24*60*60;
>> timeDiff = secsPerDay * (d2-d1)
timeDiff =
      0.019996

I have now posted an article about this on http://undocumentedmatlab.com/blog/datenum-performance/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜