function yy=LPbutterworth(dr,dt,T)
%%% dr - signal to filter with
%%% dt - sampling rate (min)
%%% T -  shortest period at the output (min)

wc=tan(pi*dt/T);

b0=1+wc*wc+wc;
c0=wc*wc/b0;
c1=2*c0;
c2=c0;
b1=2.*(1.-wc*wc)/b0;
b2=(wc-1.-wc*wc)/b0;
cc1=wc/(1.+wc);
bb1=(1.-wc)/(1+wc);

CC=[c0 c1 c2];
BB=[b1 b2];
CC_1=[cc1 cc1];
BB_1=[bb1];

clear y;
y=recursfilt(dr,BB,CC);
y=recursfilt(y,BB_1,CC_1);

n=length(y);
time=1:n;
tm=time-1/wc;  % filtered signal is shifted in time
yy=spline(tm,y,time);  % recalculate to original sampling moments

return
end

function y=recursfilt(x,d,c)

K=length(x);
N=length(d);
M=length(c);
mn=max([N+1 M]);
clear y;
y(1:K)=x(1);

for k=mn:K
s=0;
for i=1:N
   s=s+d(i)*y(k-i);
end
for i=1:M
   s=s+c(i)*x(k+1-i);
end
y(k)=s;
end

end