Hi,

I have gone through all the discussion.

Like Sat Kumar I too found your code is perfectly fine.

I tested your code in Matlab. It is giving correct result.

I have already applied sen's slope to find out trend magnitude in annual maximum temperature of (EC) East Coast region (temperature homogeneous region defiened by IMD) for the period 1901-2003.

Validated result is mentioned in the following link

http://www.sciencedirect.com/science/article/pii/S0022169412009341To validate your code I applied the same to find out trend and I got the same result (keeping dt=1).

Result from your code is matching with the result mentioned in the given article. [page-220; Table-2]

trend magnitude=0.0023

Mann-Kendall Test:

n = 103

Mean Value = 36.5718

Z statistic = 0.9717

No significant trend

Sen's Nonparametric Estimator:

Slope Estimate = 0.0022727

Lower Confidence Limit = -0.0022989

Upper Confidence Limit = 0.0076923

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Result from the code used in the mentioned article:-

b=0.0022727~0.0023;

Regards,

Sonali