该代码是在小时均值的基础上增加的新功能。分钟值会出现0值的问题,增加了0值是否参与计算
自动计算开始和结束时间
时间必须是数字格式
基础代码是我师兄的。代码虽然简单,但很实用。希望对大家有帮助
function rhourly=avg_h(x,n_t,flag,to,te,t_shift)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 功能:小时均值统计 hourly means,包含0值统计和不统计,由flag控制
% format:
% rhourly=avg_h(x,n_t,flag,to,te,t_shift)
% % t_shift: e.g.
%
% for i=1:n
% o=x(:,1)>to+t_shift+(i-1)/24&x(:,1)<=to+t_shift+i/24;
% ...
% end
%
% 默认t_shift=1/60/24 (1分钟)
% Input Argument:
% x (required) read data and column datetime in matrix must be time in form of Julian day
% n_t (required) sequence number of column in datetime
% flag (optional) if true (default), x calculate include zeros value, if