converting from integer time to datetime in 3-hourly data
이전 댓글 표시
I've tried everything I can think of to convert from integer time to datetime. Anyone have any intuitions or suggestions? Thanks!
time
Size: 13208x1
Dimensions: record
Datatype: double
Attributes:
standard_name = 'time'
long_name = 'Time'
units = 'hours since 1979-12-01 00'
time_calendar = 'gregorian'
start = '1979120100'
step = '3'
With having a time step of '3' I'm not sure how to apply the datetime function.
For reference:
>> time(1)
ans =
176064
댓글 수: 6
Carrie Merritt
2020년 12월 1일
My answer moved here:
X = {'1979120100', '1979120103', '1979120106'}
T = datetime(X,'InputFormat','yyyyMMddhh','Format','yyyy-MM-dd HH:mm')
result is:
T =
1×3 datetime array
1979-12-01 00:00 1979-12-01 03:00 1979-12-01 06:00
Some calculation:
>> T(3)-T(1)
ans =
duration
06:00:00
Stephan
2020년 12월 1일
Carries comment moved here:
Hi Stephan,
Thanks for the response. If you notice, I referenced the first time integer (e.g., time(1) = 176064). The method you have suggested assumes I already have a time vector in the 'yyyyMMddHH' format. Which I do not. It is what I need though.
I'm not sure what kind of time units I'm working with aside from what information I have in the netCDF file.
Stephan
2020년 12월 1일
I see, can you attach the data object you have there?
Carries comment moved here:
Please see attached. There isn't anything on the script aside from my numerous failed attempts at trying to make this work. All I'm trying to do is read the time in and convert it from its original netCDF format to a date/time format.
Walter Roberson
2020년 12월 1일
Is it possible that the first time should be 05-Jun-1982 ?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
