 ## -*- texinfo -*-
 ## @deftypefn {} {@var{eqBW} =} enbw (@var{window})
 ## @deftypefnx {} {@var{eqBW} =} enbw (@var{window}, @var{fs})
 ## Compute the Equivalent Noise Bandwidth (ENBW) of a window.
 ## Equivalent noise bandwidth is the width of a rectangular window that has the 
 ## same area as the supplied window.
 ## If fs is supplied, then the result is scaled by the frequency resolution.
 ## See: https://www.gaussianwaves.com/2011/02/window-functions-an-analysis/ 
 ## for an easy to understand reference.
function eqBW = enbw(window, varargin)
  ## Make window a column vector if required.
  if (size(window, 1) == 1)
    window = window(:);
  endif
  fs = size(window, 1);
  win_size = fs;
  if (nargin > 1)
    fs = varargin{1};
  elseif (nargin > 2)    
    evalin ("caller", "print_usage");
  endif
  if (! (isscalar (fs) && fs > 0))
        error ("pwelch: FS must be a scalar greater than 0");
  endif
  
  eqBW = mean(window.^2)./mean(window).^2 * fs/win_size;
endfunction
