Ingesting fractional second timestamps

3 ビュー (過去 30 日間)
Tim
Tim 2015 年 7 月 8 日
コメント済み: Tim 2015 年 7 月 8 日
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;

採用された回答

dpb
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
>>
  1 件のコメント
Tim
Tim 2015 年 7 月 8 日
That is exactly what I was hoping was actually happening, thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by