Hello,
I have a time variable (attached) that I created from using
netcdf_time = ncread('sample.netcdf','time');
When I use ncdisp on the netcdf file, time is described as the following:
time Size: 102272x1 Dimensions: time Datatype: int32 Attributes: units = 'hours since 1900-01-01 00:00:0.0' long_name = 'time' calendar = 'gregorian'
My question is, what do I do with the netcdf_time variable to get the time into matlab datenum format while retaining the 'hour'. I have used this based on online phishing
time = double(netcdf_time/24 + datenum('1900-01-01 00:00:00'));
But, datestr(time(1:7,1),'dd-mm-yyyy HH:MM:SS') returns
01-01-1980 00:00:0001-01-1980 00:00:0001-01-1980 00:00:0002-01-1980 00:00:0002-01-1980 00:00:0002-01-1980 00:00:0002-01-1980 00:00:00
When it should return
01-01-1980 03:00:0001-01-1980 06:00:0001-01-1980 09:00:0001-01-1980 12:00:0001-01-1980 15:00:0001-01-1980 18:00:0001-01-1980 21:00:00
Any ideas?
Best Answer