function [xs] = runav(x,n)
%
%  This applies a running average over n points. It returns an array (n-1) points shorter.
%
m=max(size(x));
ns=floor((n-1)/2);
xs=zeros(1,m-2.*ns);
for i=1+ns:m-ns
   sum=0;
   for j=i-ns:i+ns
      sum=sum+x(j);
   end   
   xs(i-ns)=sum./(2.*ns+1);
end 