ncreadtime.m 392 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
% Read a time variable as serial day number.
% 
% t = ncreadtime(filename,varname)
%
% Read a time variable called varname from the file called filename as serial 
% day number (days since 31 December 1 BC, as datenum).

function t = ncreadtime(filename,varname)

10
t = double(ncread(filename,varname));
11 12 13 14 15
units = ncreadatt(filename,varname,'units');

[t0,f] = nctimeunits(units);

t = f*t + t0;