How to convert the following UTC to serial date number?

23 次查看(过去 30 天)
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);

采纳的回答

Walter Roberson
Walter Roberson 2022-1-25
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 个评论
Steven Lord
Steven Lord 2022-1-25
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by