필터 지우기
필터 지우기

How to convert the following UTC to serial date number?

조회 수: 16 (최근 30일)
Anirban Mandal
Anirban Mandal 2022년 1월 25일
댓글: Steven Lord 2022년 1월 25일
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