Ingesting fractional second timestamps

1 visualizzazione (ultimi 30 giorni)
Tim
Tim il 8 Lug 2015
Commentato: Tim il 8 Lug 2015
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;

Risposta accettata

dpb
dpb il 8 Lug 2015
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 Commento
Tim
Tim il 8 Lug 2015
That is exactly what I was hoping was actually happening, thank you.

Accedi per commentare.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by