How to make time string from seconds of each year (total 11 years) to year (for 11 years)

조회 수: 2 (최근 30일)
Dear all,
I have a time series data set from 2008 to 2019. Where 1st column is for year and 2nd column (time interval is 300 seconds =5 minutes) is for seconds of each year (i,e, for each year time starts from 0000 seconds). But I need to study for 2008 to 2019 (continuously). How can I make continuous time from January, 2008 to December, 2019 with the same interval (5 minutes) of time?
Thanks in advance.

채택된 답변

Voss
Voss 2022년 4월 16일
dt = datetime('2008-01-01 00:00:00'):minutes(5):datetime('2019-12-31 23:55:00');
dt(1:10).'
ans = 10×1 datetime array
01-Jan-2008 00:00:00 01-Jan-2008 00:05:00 01-Jan-2008 00:10:00 01-Jan-2008 00:15:00 01-Jan-2008 00:20:00 01-Jan-2008 00:25:00 01-Jan-2008 00:30:00 01-Jan-2008 00:35:00 01-Jan-2008 00:40:00 01-Jan-2008 00:45:00
dt(end-9:end).'
ans = 10×1 datetime array
31-Dec-2019 23:10:00 31-Dec-2019 23:15:00 31-Dec-2019 23:20:00 31-Dec-2019 23:25:00 31-Dec-2019 23:30:00 31-Dec-2019 23:35:00 31-Dec-2019 23:40:00 31-Dec-2019 23:45:00 31-Dec-2019 23:50:00 31-Dec-2019 23:55:00
  댓글 수: 6
Voss
Voss 2022년 4월 18일
I think using datetime is the best way to go, yes.
You can easily add the seconds 'offset' from the beginning of each year using the seconds function
datetime('2008-01-01')+seconds(300)
ans = datetime
01-Jan-2008 00:05:00
datetime(2008,1,1)+seconds(300) % same
ans = datetime
01-Jan-2008 00:05:00
datetime(2008,1,1)+seconds(300:300:30000).'
ans = 100×1 datetime array
01-Jan-2008 00:05:00 01-Jan-2008 00:10:00 01-Jan-2008 00:15:00 01-Jan-2008 00:20:00 01-Jan-2008 00:25:00 01-Jan-2008 00:30:00 01-Jan-2008 00:35:00 01-Jan-2008 00:40:00 01-Jan-2008 00:45:00 01-Jan-2008 00:50:00 01-Jan-2008 00:55:00 01-Jan-2008 01:00:00 01-Jan-2008 01:05:00 01-Jan-2008 01:10:00 01-Jan-2008 01:15:00 01-Jan-2008 01:20:00 01-Jan-2008 01:25:00 01-Jan-2008 01:30:00 01-Jan-2008 01:35:00 01-Jan-2008 01:40:00 01-Jan-2008 01:45:00 01-Jan-2008 01:50:00 01-Jan-2008 01:55:00 01-Jan-2008 02:00:00 01-Jan-2008 02:05:00 01-Jan-2008 02:10:00 01-Jan-2008 02:15:00 01-Jan-2008 02:20:00 01-Jan-2008 02:25:00 01-Jan-2008 02:30:00

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by