function [Y] = taperEnds(X,Nend);
% Usage: [Y] = taperEnds(X,Nend);
%   cosine bell taper of two ends of time seris
%    (using first and last Nend points)
[n,m] = size(X);
Trans = (n==1);
if Trans 
   Y = X';
else
   Y = X;
end

nX = length(X);
%w = sin(pi*[1:Nend ]/(2*Nend));
w = (1-cos(2*pi*[1:Nend ]/(2*Nend)))/2;
w = w';
Y(1:Nend) = w.*Y(1:Nend);
Y(end:-1:end-Nend+1) = w.*Y(end:-1:end-Nend+1);

if Trans 
   Y = Y';
end
