function fraction=fractionTime2(x,y,th1) % FRACTIONTIME2 calculates the fraction of time % where the number of visits to each site (recurrence) % is below given threshold. % % In order to improve SNR, total visits to three % consecutive sites are computed. % % X,Y - positions % TH1 - threshold % C1=CircleMethod3(x,y); %number of visits C1=C1(~isnan(C1)); n=length(C1); for i=1:floor(n/3) CC(i)=sum(C1(3*(i-1)+1:3*(i-1)+3)); %add visits from 3 consecutive sites end CCnew=[CC;CC;CC]; CCnew1=reshape(CCnew,1,floor(n/3)*3); f1=(find(CCnew1>th1)); l=length(f1); fraction=l/(floor(n/3)*3);