Filter löschen
Filter löschen

Apply Mann-Kendall Test on a matrix

2 Ansichten (letzte 30 Tage)
Nahid Atashi
Nahid Atashi am 24 Jul. 2019
Hello friends, me again
I have the code below for calcute Mann-Kendall test. this code only works for a vector but i would like to apply it on a matrix with 40*5260
when i try to do it for an example like a 40*10 i don't get error but only give me one H nad p-value, rather than 10 H, p-value.
sorry it might be simple but i'm not good in Matlab yet
could you please help.
thanks in advance
function[H,p_value]=Mann_Kendall(V,alpha) %% alpha can be 0.05
V=reshape(V,size(V),1);
alpha = alpha/2; %
n=length(V);
i=0; j=0; S=0;
for i=1:n-1
for j= i+1:n
S= S + sign(V(j)-V(i));
end
end
VarS=(n*(n-1)*(2*n+5))/18;
StdS=sqrt(VarS);
%%%% Note: ties are not considered
if S >= 0
Z=((S-1)/StdS)*(S~=0);
else
Z=(S+1)/StdS;
end
p_value=2*(1-normcdf(abs(Z),0,1)); %% Two-tailed test
pz=norminv(1-alpha,0,1);
H=abs(Z)>pz; %%
return

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by