date conversions from yyyydddhhmmss to the number format

3 visualizaciones (últimos 30 días)
Jack Shue
Jack Shue el 24 de Jun. de 2019
Editada: Adam Danz el 24 de Jun. de 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

Respuesta aceptada

Adam Danz
Adam Danz el 24 de Jun. de 2019
Editada: Adam Danz el 24 de Jun. de 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).

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by