C***************************************************
C* N: SAMPLE SIZE *
C* NYEAR: FIRST YEAR OF THE TIME SERIES*
C* Y(N): ORIGINAL TIME SERIES *
C* UF(N): ORIGINAL SERIES OF U(LN) *
C* UB(N): COUNTER SERIES OF U(LN) *
C* A,B: CRITICAL VALUE 1.96 AND -1.96*
C***************************************************
程序盯搭中 READ 语句是读入对应数据的,先返卖读入N,NYEAR,然后读入N个Y(N),但是没有读入UF(N),看说明语句也应该是原始数据。
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) (2 k+5)/72
U(k) = (s(k)-E)/sqrt(VAR)
end
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)