Ingesting fractional second timestamps

1 vue (au cours des 30 derniers jours)
Tim
Tim le 8 Juil 2015
Commenté : Tim le 8 Juil 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;

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by