Home > classes > @specwin > specwin.m

specwin

PURPOSE ^

SPECWIN spectral window object class constructor.

SYNOPSIS ^

function w = specwin(varargin)

DESCRIPTION ^

 SPECWIN spectral window object class constructor.

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

 DESCRIPTION: SPECWIN spectral window object class constructor.
              Create a spectral window from libSpecWin.

  PROPERTIES:
       name     - name of window object
       alpha    - alpha parameter for various window functions
       psll     - peak sidelobe level
       rov      - recommended overlap
       nenbw    - normalised equivalent noise bandwidth
       w3db     - 3 dB bandwidth in bins
       flatness - window flatness
       ws       - sum of window values
       ws2      - sum of squares of window values
       nfft     - window length
       win      - window samples

  CONSTRUCTORS:

       w = specwin()                  - creates an empty object
       w = specwin(w)                 - copies a specwin object
       w = specwin('name', N)         - creates a specwin object of a
                                        particular type and length.
                                        (see below for supported types.)
       w = specwin('Kaiser', N, psll) - create a specwin Kaiser window
                                        with the prescribed psll.
       w = specwin('Types')           - return a list of all possible
                                        standard windows

 'name' should be one of the following standard windows:

    Rectangular, Welch, Bartlett, Hanning, Hamming,
    Nuttall3, Nuttall4, Nuttall3a, Nuttall3b, Nuttall4a
    Nuttall4b, Nuttall4c, BH92, SFT3F, SFT3M, FTNI, SFT4F, SFT5F
    SFT4M, FTHP, HFT70, FTSRS, SFT5M, HFT90D, HFT95, HFT116D
    HFT144D, HFT169D, HFT196D, HFT223D, HFT248D

 VERSION:     $Id: specwin.m,v 1.17 2008/01/11 14:05:13 ingo Exp $

 HISTORY:     30-01-07 M Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function w = specwin(varargin)
0002 % SPECWIN spectral window object class constructor.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: SPECWIN spectral window object class constructor.
0007 %              Create a spectral window from libSpecWin.
0008 %
0009 %  PROPERTIES:
0010 %       name     - name of window object
0011 %       alpha    - alpha parameter for various window functions
0012 %       psll     - peak sidelobe level
0013 %       rov      - recommended overlap
0014 %       nenbw    - normalised equivalent noise bandwidth
0015 %       w3db     - 3 dB bandwidth in bins
0016 %       flatness - window flatness
0017 %       ws       - sum of window values
0018 %       ws2      - sum of squares of window values
0019 %       nfft     - window length
0020 %       win      - window samples
0021 %
0022 %  CONSTRUCTORS:
0023 %
0024 %       w = specwin()                  - creates an empty object
0025 %       w = specwin(w)                 - copies a specwin object
0026 %       w = specwin('name', N)         - creates a specwin object of a
0027 %                                        particular type and length.
0028 %                                        (see below for supported types.)
0029 %       w = specwin('Kaiser', N, psll) - create a specwin Kaiser window
0030 %                                        with the prescribed psll.
0031 %       w = specwin('Types')           - return a list of all possible
0032 %                                        standard windows
0033 %
0034 % 'name' should be one of the following standard windows:
0035 %
0036 %    Rectangular, Welch, Bartlett, Hanning, Hamming,
0037 %    Nuttall3, Nuttall4, Nuttall3a, Nuttall3b, Nuttall4a
0038 %    Nuttall4b, Nuttall4c, BH92, SFT3F, SFT3M, FTNI, SFT4F, SFT5F
0039 %    SFT4M, FTHP, HFT70, FTSRS, SFT5M, HFT90D, HFT95, HFT116D
0040 %    HFT144D, HFT169D, HFT196D, HFT223D, HFT248D
0041 %
0042 % VERSION:     $Id: specwin.m,v 1.17 2008/01/11 14:05:13 ingo Exp $
0043 %
0044 % HISTORY:     30-01-07 M Hewitson
0045 %                 Creation
0046 %
0047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0048 
0049 %       w = specwin('Flattop', N, psll) - create a specwin Flattop window
0050 %                                         with the prescribed psll.
0051 
0052 VERSION  = '$Id: specwin.m,v 1.17 2008/01/11 14:05:13 ingo Exp $';
0053 
0054 % Check if this is a call for parameters
0055 if nargin == 2
0056   if isa(varargin{1}, 'specwin') && ischar(varargin{2})
0057     in = char(varargin{2});
0058     if strcmp(in, 'Params')
0059       w = plist();
0060       return
0061     elseif strcmp(in, 'Version')
0062       w = VERSION;
0063       return
0064     end
0065   end
0066 end
0067 
0068 %%%%%%%%%%%%%%%%%%%%   define parameter properties list   %%%%%%%%%%%%%%%%%%%%%
0069 
0070   function w = init()
0071 
0072     w.name     = 'no window';
0073     w.alpha    = -1;
0074     w.psll     = -1;
0075     w.rov      = -1;
0076     w.nenbw    = -1;
0077     w.w3db     = -1;
0078     w.flatness = -1;
0079     w.ws       = -1;
0080     w.ws2      = -1;
0081     w.win      = -1;
0082     w.created  = '';
0083     w.version  = VERSION;
0084   end
0085 
0086 
0087 
0088 %%%%%%%%%%   spw = specwin()   %%%%%%%%%%
0089 if nargin == 0
0090 
0091   w = init();
0092   w = class(w, 'specwin');
0093 
0094 elseif nargin == 1
0095   if isa(varargin{1}, 'org.apache.xerces.dom.DeferredElementImpl')
0096     w = fromxml(varargin{1});
0097 
0098   %%%%%%%%%%   spw = specwin(specwin)   %%%%%%%%%%
0099   elseif isa(varargin{1}, 'specwin')
0100     w = varargin{1};
0101 
0102   %%%%%%%%%%   spw = specwin(struct)   %%%%%%%%%%
0103   elseif isstruct(varargin{1})
0104 
0105     w = class(varargin{1}, 'specwin');
0106     return
0107 
0108   %%%%%%%%%%   spw = specwin(plist)   %%%%%%%%%%
0109   elseif isa(varargin{1}, 'plist')
0110 
0111     pl    = varargin{1};
0112     wname = find(pl, 'Name');
0113     N     = find(pl, 'N');
0114     psll  = find(pl, 'PSLL');
0115 
0116     switch wname
0117       case 'Kaiser'
0118         w = specwin(wname, N, psll);
0119       otherwise
0120         w = specwin(wname, N);
0121     end
0122 
0123   elseif ischar(varargin{1})
0124 
0125     %%%%%%%%%%   spw = specwin('Types')   %%%%%%%%%%
0126     if strcmp(varargin{1}, 'Types')
0127 
0128       % return list of windows
0129       w = {...
0130         'Rectangular', 'Welch', 'Bartlett', 'Hanning', 'Hamming',...
0131         'Nuttall3', 'Nuttall4', 'Nuttall3a', 'Nuttall3b', 'Nuttall4a',...
0132         'Nuttall4b', 'Nuttall4c', 'BH92', 'SFT3F', 'SFT3M', 'FTNI', 'SFT4F', 'SFT5F',...
0133         'SFT4M', 'FTHP', 'HFT70', 'FTSRS', 'SFT5M', 'HFT90D', 'HFT95', 'HFT116D',...
0134         'HFT144D', 'HFT169D', 'HFT196D', 'HFT223D', 'HFT248D'...
0135         };
0136 
0137     %%%%%%%%%%   spw = specwin('foo.xml')   %%%%%%%%%%
0138     else
0139 
0140       filename = varargin{1};
0141       [path, name, ext, vers] = fileparts(filename);
0142       switch ext
0143         case '.mat'
0144           w = load(filename);
0145           w = w.a;
0146         case '.xml'
0147           w = xmlparse(specwin('Hanning', 1), filename);
0148         otherwise
0149           error('### Unknown file type.');
0150       end
0151 
0152     end
0153 
0154   else
0155     error('### unknown constructor type for specwin object.');
0156   end
0157 
0158 elseif nargin == 2
0159 
0160   %%%%%%%%%%   copy specwin   %%%%%%%%%%
0161   %%%%%%%%%%   spw = specwin(specwin, ...)   %%%%%%%%%%
0162   if isa(varargin{1}, 'specwin')
0163     w = varargin{1};
0164     w.created = '';
0165     w.version = VERSION;
0166 
0167   %%%%%%%%%%   spw = specwin(database, ...)   %%%%%%%%%%
0168   elseif isa(varargin{1}, 'database')
0169 
0170     w = retrieve(varargin{1}, varargin{2:end});
0171 
0172   %%%%%%%%%%   create a particular type   %%%%%%%%%%
0173   %%%%%%%%%%   spw = specwin('Win_type', N)   %%%%%%%%%%
0174   elseif ischar(varargin{1})
0175 
0176     w = get_window(varargin{1}, varargin{2});
0177     w.created = '';
0178     w.version = VERSION;
0179     w = class(w, 'specwin');
0180 
0181   else
0182     error('### unknown constructor for specwin object.')
0183   end
0184 
0185 %%%%%%%%%%   create a Kaiser window   %%%%%%%%%%
0186 %%%%%%%%%%   spw = specwin('Kaiser', N, psll)   %%%%%%%%%%
0187 elseif nargin == 3
0188 
0189   w = get_window(varargin{1}, varargin{2}, varargin{3});
0190   w.created = '';
0191   w.version = VERSION;
0192   w = class(w, 'specwin');
0193 
0194 else
0195   error('### Unknown number of constructor arguments.');
0196 end
0197 
0198 end
0199

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003