function y=denoise(x,n,p) % DENOISE % y = denoise(x,n,p) performs the following on the data stored in % columns of x: % 1) n-time differentiation % 2) p-point smoothing % 3) n-time integration % the result os of same length as x for convenience. % For notes on possible zero-padding artifacts, see SMOOTH and NDIFF. [yd,c] = ndiff(x,n); f=mean(yd); ys = smooth(yd,p); yi=ys-mean(ys) + f; for m=1:n, yi=cumsum(yi); yi=yi-mean(yi)+c(n+1-m,:); end y=yi;