function [y] = smooth(x,n) % SMOOTH % y=smooth(x,n) performs n-point smoothing on spectra contained in the % vector x. If x is a matrix, then smoothing is performed column-wise. % Before smoothing, x is padded with its edge values on both ends so that the % output spectra y are of the same length as x. This should be taken % into consideration when using information near the ends of the spectra. % % RJM 5/8/94 % Marcel's old smoothing routine is now called msmooth. p=floor(n/2); q=n-p; [i,j]=size(x); xt = [ ones(p,1)*x(1,:);x;ones(q,1)*x(i,:)]; sux=sum(xt(1:n,:)); y=sux/n; for k = 2:i, sux=sux-xt(k-1,:)+xt(k+p,:); y=[y; sux/n]; end