function [ UF ] = MannKendall( Runoff )
%UNTITLED
%runoff
%a=size(Data);
%b=max(a);
%Year=Data(:,1);
%Runoff=Data(:,2);
a=size(Runoff);
b=max(a);
r=[];
for i=1:b
xi=Runoff(i);
xj=Runoff(1:i);
R=xj(xj<xi);
m=size(R);
if min(m)==0
r_v=0;
else
r_v=max(m);
end
r=[r;r_v];
end
%create s
s=zeros(b,1);
for j=1:b
s(j)=sum(r(1:j));
end
% create UF
UF=[];
for k=2:b
E_sk=k*(k-1)/4;
Var_sk=k*(k-1)*(2*k+5)/72;
UF_k=(s(k)-E_sk)./(Var_sk.^0.5);
UF=[UF;UF_k];
end
UF=[0;UF];
end
评论0