function P=boxsmooth(A,bsize)

[na,nr]=size(A);
 if na==1
     A=A';
 end
 nb=floor(bsize/2);
 
 P=A;
 
 for j=nb+1:length(A)-nb
     P(j)=mean(A(j-nb:j+nb));
 end
 
 for j=nb:-1:1
     P(j)=mean(P(1:j+nb));
 end
 for j=(length(A)-nb+1):length(A)
     P(j)=mean(P(j:length(A)));
 end
 return