开发者

MATLAB date format

开发者 https://www.devze.com 2023-03-01 07:54 出处:网络
I\'m trying to convert date string to date number using dtstr2dtnummx (three time faster than datenum), but for this input

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

精彩评论

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