I found exactly what i was doing..however, i am getting an error message of too many output argument.Any help would be appreciated.
function [H,P] = mann_kendall(x,alpha)
i=0; j=0; S=0;
for i = 1:n-1
S = S + sign(x(j) - x(i));
VS=(n*(n-1))*(2*n+5)/18; % Variance
De=sqrt(VS); % Standard Deviation
if S >= 0;
P=2*(1-normcdf(abs(Z),0,1)); % tail on both side
pz = norminv(1-alpha,0,1);
There seems to be a bug in
[V,I]=sort(V); %% I = ranks
IMHO the variable "I" contains the indexes of the values of "V"
rather than the ranks.
From my side of view
I = tiedrank(V);
should be used here instead.