[m n]=size(data); Lead=1; d=abs(resample(diff(resample(data(:,Lead),1,10)),10,1)); hh=sort(d); md=int32(m*5.5/6); MeanD=hh(md); j=0; i=200; while i