📄 yf2num.m
字号:
function[num]=yf2num(yf)%YF2NUM Convert date in 'year.fraction' format to 'datenum' format.%% YF2NUM(YF) where YF is an array of dates in 'year.fraction' format% returns the array in Matlab's 'datenum' format.%% See also NUM2YF, DATENUM, DATEVEC% __________________________________________________________________% This is part of JLAB --- type 'help jlab' for more information% (C) 2000, 2004 J.M. Lilly --- type 'help jlab_license' for details if strcmp(yf, '--t') yf2num_test,returnendy=floor(yf);%Number of days in this year?d0=datenum(y-1,12,31);d1=datenum(y,12,31);nd=d1-d0;num=d0+nd.*(yf-y)+1;function[]=yf2num_testyearf=[1850:(1/360):2004]';num=yf2num(yearf);yearf2=num2yf(num);bool=maxmax(abs(yearf-yearf2))<1e-10;reporttest('YF2NUM and NUM2YF, daily resolution, 1e-10 cutoff',bool)yearf=[1990:(1/360/24):2004]';%yearf=[1850:(1/360/24):2004]';num=yf2num(yearf);yearf2=num2yf(num);bool=maxmax(abs(yearf-yearf2))<1e-10;reporttest('YF2NUM and NUM2YF, hourly resolution, 1e-10 cutoff',bool)%yearf=[1990:(1/360/24):2004]';%yearf=[1850:(1/360/24):2004]';%num2yearf(yf2num(1990))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -