Home > classes > @specwin > 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: GET_WINDOW returns the required window function as a structure.

 CALL:        objs = copy(objs, [1,0]);

 VERSION:     $Id: get_window.m,v 1.2 2008/07/14 10:40:13 ingo Exp $

 HISTORY:     18-05-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003