Reading dates/times into MATLAB and saving as a numeric vector
显示 更早的评论
I am reading in *.txt files that contain a column of dates (i.e. 17.11.2017 09:57:24.06). Each row is a signal at a frequency of 0.01 seconds. I want to be able to bring this in as a numeric vector so that I can determined time elapsed between selected rows. Using x = datenum(filename) gives me 736696.4149 (number of days from Jan 0, 0000) for both 17.11.2017 09:57:24.06 and 17.11.2017 09:57:29.96. These are 5.90 seconds apart. How do I read these dates/times in so that I can maintain the precision I need to maintain (0.01 seconds)?
采纳的回答
更多回答(1 个)
Fangjun Jiang
2018-1-5
编辑:Fangjun Jiang
2018-1-5
Don't worry. The precision is kept.
a=datenum('17.11.2017 09:57:29.96');
b=datenum('17.11.2017 09:57:24.06');
datestr(a-b,'HH:MM:SS.FFF')
datevec(a-b)
second(a-b)
ans =
'00:00:05.900'
ans =
0 0 0 0 0 5.9000
ans =
5.9000
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!