% w = window(WindowType, n, winopt)
%
% an overloaded function of matlab's window function that allows the
% construction of a window according to a string rather than a function
% pointer.
%
% Input Arguments:
% n: [1x1] window size (in samples)
% WindowType: [string] type of window. accepted types are:
% 'hamming', 'hanning', 'barthannwin', 'bartlett', 'blackman',
% 'blackmanharris', 'bohmanwin', 'chebwin', 'flattopwin',
% 'gausswin', 'hann', 'kaiser', 'nuttallwin',
% 'parzenwin', 'rectwin', 'taylorwin', 'triang', 'tukeywin'
%
% Output Arguments:
% W: [1xNf] window waveform
%
function w = ConstructWindow(WindowType, n, winopt)
switch WindowType
case 'hamming'
w = window(@hamming,n);
case 'hanning'
w = window(@hanning,n);
case 'barthannwin'
w = window(@barthannwin,n);
case 'bartlett'
w = window(@bartlett,n);
case 'blackman'
w = window(@blackman,n);
case 'blackmanharris'
w = window(@blackmanharris,n);
case 'bohmanwin'
w = window(@bohmanwin,n);
case 'chebwin'
w = window(@chebwin,n);
case 'flattopwin'
w = window(@flattopwin,n);
case 'gausswin'
w = window(@gausswin,n);
case 'hann'
w = window(@hann,n);
case 'kaiser'
w = window(@kaiser,n)
case 'nuttallwin'
w = window(@nuttallwin,n);
case 'parzenwin'
w = window(@parzenwin,n);
case 'rectwin'
w = window(@rectwin,n);
case 'taylorwin'
w = window(@taylorwin,n);
case 'triang'
w = window(@triang,n);
case 'tukeywin'
w = window(@tukeywin,n);
otherwise
error('WindowType is not recognized');
end