Convert Julian Date to Calendar Days.

조회 수: 3 (최근 30일)
Edgar
Edgar 2023년 5월 2일
답변: Cris LaPierre 2023년 5월 2일
I'm trying to Convert the Julian-Time header to include the Year header and output the format mm/dd/yyyy. i.e. 12/31/2022 & 01/01/2023.
The complete data for Book1.xlsx contains multiple years.
Thank you!

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 5월 2일
Perhaps a bit convoluted, but this appears to work. I haven't compared it extensively to the orginal data. Note that the display format only modifies how the data appears. The time is still there.
data = readtable('Book1.xlsx',"TextType","string");
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
% your Julian_dates are surrounded by quotes. Remove them
data.Julian_Time = erase(data.Julian_Time,"'");
% use datetime to convert the combined date string to a datetime.
% DDD indicates day-of-year
data.Julian_Time = datetime(data.Year+"-"+data.Julian_Time,'InputFormat','uuuu-DDD-HH:mm:ss.SSS');
data.Julian_Time.Format = 'MM/dd/yyyy'
data = 185×4 table
Year Julian_Time Data1 Data2 ____ ___________ ______ ______ 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.725 21.998 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.725 21.998 2022 12/31/2022 36.725 21.998 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.725 21.998 2022 12/31/2022 36.725 21.998 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.725 21.998 2022 12/31/2022 36.425 21.998 2022 12/31/2022 36.425 21.998

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by