function [e,A,B]=sampenc(y,M,r); %function [e,A,B]=sampenc(y,M,r); % %Input % %y input data %M maximum template length %r matching tolerance % %Output % %e sample entropy estimates for m=0,1,...,M-1 %A number of matches for m=1,...,M %B number of matches for m=1,...,M excluding last point n=length(y); lastrun=zeros(1,n); run=zeros(1,n); A=zeros(M,1); B=zeros(M,1); p=zeros(M,1); e=zeros(M,1); for i=1:(n-1) nj=n-i; y1=y(i); for jj=1:nj j=jj+i; if abs(y(j)-y1)