date conversions from yyyydddhhmmss to the number format

3 vues (au cours des 30 derniers jours)
Jack Shue
Jack Shue le 24 Juin 2019
Modifié(e) : Adam Danz le 24 Juin 2019
I have a different date format that I need to convert to the "number" format. What I have is
Data 2018:335:00:00:11 4.4960559400000193E+00 1.1337406300000055E+00
I have many lines of txt. How do I convert this one? Columns 3 & 4 are data taged at the time. The format seems to be yyyy.ddd.hh.mm.ss

Réponse acceptée

Adam Danz
Adam Danz le 24 Juin 2019
Modifié(e) : Adam Danz le 24 Juin 2019
Assuming you've already isolated the datetime strings,
% Convert string to datetime
dtstr = '2018:335:00:00:11';
dt = datetime(dtstr,'InputFormat', 'u:D:HH:mm:ss');
% if you want that in serial date format
n = datenum(dt);
If you need help isolating the strings, leave a comment (hint: regexp).
Note that the string format uses "D" for day-of-year and "u" for ISO-year in place of the Gregorian year (y).

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Produits


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by