function [ UF,UB ] = MannKendall( x,y,p )
% x表示时间如1982-2015
% y表示对应时间的结果
% p表示显著水平
N = length(y);
UF = SMK(y);
yy = reshape(y,1,length(y));
yy = fliplr(yy);
UB = -fliplr(SMK(yy));
function U = SMK( Y )
N = length(Y);
s = zeros(1,N);
U(1) = 0;
for k=2:N
r = 0;
s(k) = 0;
for j=1:k-1
if Y(k)>Y(j)
r = r+1;
end
s(k) = s(k-1)+r;
end
E = k(k-1)/4;
VAR = k(k-1)(2k+5)/72;
U(k) = (s(k)-E)/sqrt(VAR);
end