function w = myhanning(n,x)
%MYHANNING
%MYHANNING(N)   returns the N-point Hanning window in a column vector
%MYHANNING(N,X) returns the value of the N-point Hanning window
%               at distances X from center

%	modified from mathworks hanning function

% check input arguments

if nargin < 2
  x=(1:n)';
else
  if min(min(abs(x(~isnan(x))))) > (n+1)/2
    error('out of bounds vector x')
  end
  x=x+(n+1)/2;
end

% set to zero points outside window

w = zeros(size(x));
ix = find( x>0 & x<n+1 );
w(ix) = .5*(1 - cos(2*pi*x(ix)/(n+1)));
