Ingesting fractional second timestamps
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I am using the activex interface to excel to draw timestamp data from a file. The column I am drawing in is formatted as time I believe but it has an extra amount of precision. for instance the dates are of the form:
12:34:56.789
However MATLAB ingests this as a 4 digit decimal number like 0.5678 which when converted back to the time stamp later, throws away the fractional second precision. Any ideas on how to fix this? I need to match message timing with another files of the same form.
Here is my code:
dat_range = ['A25:A25000']; % Read to the last row overshoot
rngObj = exlSheet1.Range(dat_range);
exlData = rngObj.Value;
B = exlData;
clear exlData;
B(isempy(B))=[];
a.(platform).linkData.t = B;
lastrow = length(B);
clear B;
0 个评论
采纳的回答
dpb
2015-7-8
I think you're mistaking the happenstance of the value with the formatting--Matlab will import the full precision of the value as stored in Excel even though it won't display the additional precision by default. Using your values above as example (don't have your actual spreadsheet so can't demonstrate from it)
>> datenum('12:34:56.789')
ans =
7.3597e+05
>> datestr(ans)
ans =
01-Jan-2015 12:34:56
>> datestr(datenum('12:34:56.789'),'HH:MM:SS.fff')
ans =
12:34:56.789
>>
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Export to MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!