date conversions from yyyydddhhmmss to the number format

3 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Adam Danz
Adam Danz il 24 Giu 2019
Modificato: Adam Danz il 24 Giu 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).

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Prodotti


Release

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by