Home > classes > @specwin > private > get_window.m

get_window

PURPOSE ^

GET_WINDOW returns the required window function as a structure.

SYNOPSIS ^

function w = get_window(varargin)

DESCRIPTION ^

 GET_WINDOW returns the required window function as a structure.

 M Hewitson 18-05-07

 $Id: get_window.m,v 1.5 2008/02/13 18:38:02 ingo Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function w = get_window(varargin)
0002 
0003 % GET_WINDOW returns the required window function as a structure.
0004 %
0005 % M Hewitson 18-05-07
0006 %
0007 % $Id: get_window.m,v 1.5 2008/02/13 18:38:02 ingo Exp $
0008 %
0009 
0010 PSLL = [];
0011 
0012 % Get inputs
0013 if nargin == 3
0014   w    = varargin{1};
0015   name = varargin{2};
0016   N    = varargin{3};
0017 elseif nargin == 4
0018   w    = varargin{1};
0019   name = varargin{2};
0020   N    = varargin{3};
0021   PSLL = varargin{4};
0022 else
0023   error('### Incorrect inputs.');
0024 end
0025 
0026 % Get window
0027 if isempty(PSLL)
0028   % get standard window
0029   z = [0:N-1]./N;
0030   win_name = sprintf('win_%s', name);
0031   try
0032     w = feval(win_name, w, z);
0033   catch
0034     error('\n### Your window [%s] is not a supported window.\n### Please type >>specwin(''Types'') to see all supported windows.', win_name(5:end));
0035   end
0036 
0037 else
0038 
0039   % Deal with Kaiser
0040   w = get_kaiser_window(w, N, PSLL);
0041 
0042 end
0043 
0044 %--------------------------------------------------------------------------
0045 % Make Kaiser window
0046 %
0047 function w = get_kaiser_window(w, N, psll)
0048 
0049 % Make window struct
0050 w.name     = 'Kaiser';
0051 w.alpha    = kaiser_alpha(psll);
0052 w.psll     = psll;
0053 w.rov      = kaiser_rov(w.alpha);
0054 w.nenbw    = kaiser_nenbw(w.alpha);
0055 w.w3db     = kaiser_w3db(w.alpha);
0056 w.flatness = kaiser_flatness(w.alpha);
0057 
0058 % Compute window samples
0059 % - here we adjust to make the window asymmetric
0060 v = kaiser(N+1, pi*w.alpha);
0061 v = v(1:end-1);
0062 w.ws       = sum(v);
0063 w.ws2      = sum(v.*v);
0064 w.win      = v.';
0065 
0066 
0067 % END

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003