convert datenum to date time series
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi,
I have a ncfile with datenum values <ftp://ftp.cdc.noaa.gov/Datasets/cpc_global_temp/>. Since I have to adjust the time series with another set of data, I tried to convert them to date time series but the values are off. I tried some solution given in MathWorks but non of them worked.
The nc file says:
time
Size: 365x1
Dimensions: time
Datatype: double
Attributes:
long_name = 'Time'
axis = 'T'
standard_name = 'time'
coordinate_defines = 'start'
actual_range = [1008072 1016808]
units = 'hours since 1900-01-01 00:00:00'
delta_t = '0000-00-01 00:00:00'
avg_period = '0000-00-01 00:00:00'
How needs to be the conversion from their datenum to MATlab's datenum? Or is there another way to do it?
Any help is appreciated.
Thanks.
댓글 수: 1
Stephen23
2018년 7월 3일
I think you will have to do this conversion yourself: all of the datetime conversions are for days or seconds since some epoch, but I don't see any that is hours since an epoch.
채택된 답변
Peter Perkins
2018년 7월 5일
You can do this:
>> datetime(1900,1,1,0,0,0) + hours([1008072 1016808])
ans =
1×2 datetime array
01-Jan-2015 00:00:00 31-Dec-2015 00:00:00
Or this (but more typing):
>> datetime([1008072 1016808]*3600,'ConvertFrom','EpochTime','Epoch',datetime(1900,1,1,0,0,0))
ans =
1×2 datetime array
01-Jan-2015 00:00:00 31-Dec-2015 00:00:00
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!