【文件属性】:
文件名称:MK检验程序出错有请大侠-MK.m
文件大小:2KB
文件格式:M
更新时间:2022-09-02 02:29:33
matlab
MK检验程序出错有请大侠-MK.m
% Time Series Trend Detection Tests
%
% [ z, sl, lcl, ucl ] = trend
%
% where z = Mann-Kendall Statistic
% sl = Sen's Slope Estimate
% lcl = Lower Confidence Limit of sl
% ucl = Upper Confidence Limit of sl
% y = Time Series of Data
% dt = Time Interval of Data
%
% Bob Newell, February 1996
%
%--------------------------------------------------
%
load unnamed1.mat;
y=unnamed1;
function [ z, sl, lcl, ucl ] = trendMK
%
n = length;
%--------------------------------------------------
% Mann-Kendall Test for N > 40
%
disp;
if n < 41,
disp;
end;
% calculate statistic
s = 0;
for k = 1:n-1,
for j = k 1:n,
s = s sign - y );
end;
end;
% variance
v = * ) / 18;
% test statistic
if s == 0,
z = 0;
elseif s > 0,
z = / sqrt;
else
z = / sqrt;
end;
% should calculate Normal value here
nor = 1.96;
% results
disp ] );
disp ) ] );
disp ] );
if abs < nor,
disp;
z = 0;
elseif z > 0,
disp;
else
disp;
end;
%----------------------------------------------------
%
disp;
% calculate slopes
ndash = n * / 2;
s = zeros;
i = 1;
for k = 1:n-1,
for j = k 1:n,
s = - y ) / / dt;
i = i 1;
end;
end;
% the estimate
sl = median;
disp ] );
% variance
v = * ) / 18;
m1 = fix ) / 2 );
m2 = fix ) / 2 );
s = sort;
lcl = s;
ucl = s;
disp( [ ' Lower Confidence Limit = ' ...
num2str ] );
disp( [ ' Upper Confidence Limit = ' ...
num2str ] );
%----------------------------------------------------
% the end