convert narr model data time to datevec or datestr
1 view (last 30 days)
Show older comments
I have a set of model data that has time attributes:
Attributes:
units = 'hours since 1800-1-1 00:00:0.0'
long_name = 'Time'
axis = 'T'
standard_name = 'time'
coordinate_defines = 'start'
delta_t = '0000-00-01 00:00:00'
actual_range = [1.74e+06 1.75e+06]
avg_period = '0000-00-01 00:00:00'
When I pull a sample time such as time(1:5) I get:
1744392
1744416
1744440
1744464
1744488
When trying to convert to date string using datestr(time(1)) I get: 25-Dec-4775. I try putting in a pivot year of 1800 but still get the same result. What am I doing wrong? The result should be Jan 1st 1999.
2 Comments
Accepted Answer
dpb
on 10 Jul 2014
>> dn1800=datenum(1800,1,1) % baseline point in Matlab datenum
dn1800 =
657438
>> datestr(dn1800+1744392/24) % add that many hours in days...
ans =
01-Jan-1999
The better way...
>> datestr(addtodate(dn1800,1744392,'hour'))
ans =
01-Jan-1999
>>
More Answers (1)
dpb
on 11 Jul 2014
Seems ok to me...
>> (datenum(1999,1,1)-dn1800)*24
ans =
1744392
Convert the days to hours from the reference point.
See Also
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!