Borrar filtros
Borrar filtros

How to convert the following UTC to serial date number?

16 visualizaciones (últimos 30 días)
I have a UTC data in the format YYYY-DOYThh:mm:ss.fffZ (Example-2018-345T02:19:02.175Z). What format can I use for it to convert it into serial date number using datenum? The main issue I am facing is with the format DOY as I wasn't able to find any suitable format for this in the datenum documentation. However, I can take care of the rest of them easily. Here I am attaching a sample code I used for this case. The first line is there as I am extracting UTC from a dataset.
utc_t=data(:,5);
match=["T","Z"];
utc=erase(utc_t,match);
format='yyyy-HH:MM:SS:FFF';%This is incomplete as I have not incorporated DOY format here
time=datenum(utc,format);

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de En. de 2022
format long g
utc_t = '2018-345T02:19:02.175Z'
utc_t = '2018-345T02:19:02.175Z'
utc_dt = datetime(utc_t, 'InputFormat', "uuuu-DDD'T'HH:mm:ss.SSS'Z'")
utc_dt = datetime
11-Dec-2018 02:19:02
time = datenum(utc_dt)
time =
737405.096552951
  2 comentarios
Steven Lord
Steven Lord el 25 de En. de 2022
Unless you absolutely need to work with the serial date numbers, I'd advise you to work with the datetime array utc_dt instead of the double array time. You should be able to do just about everything with datetime that you could do with the date numbers. If you find something you can do with datenums that you can't with datetime, please describe what you're trying to do.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by