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(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. '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.13 2007/08/31 17:40:08 hewitson Exp $ HISTORY: 30-01-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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(w) - copies a specwin object 0025 % w = specwin('name', N) - creates a specwin object of a 0026 % particular type and length. 0027 % (see below for supported types.) 0028 % w = specwin('Kaiser', N, psll) - create a specwin Kaiser window 0029 % with the prescribed psll. 0030 % 0031 % 'name' should be one of the following standard windows: 0032 % 0033 % Rectangular, Welch, Bartlett, Hanning, Hamming, 0034 % Nuttall3, Nuttall4, Nuttall3a, Nuttall3b, Nuttall4a 0035 % Nuttall4b, Nuttall4c, BH92, SFT3F, SFT3M, FTNI, SFT4F, SFT5F 0036 % SFT4M, FTHP, HFT70, FTSRS, SFT5M, HFT90D, HFT95, HFT116D 0037 % HFT144D, HFT169D, HFT196D, HFT223D, HFT248D 0038 % 0039 % VERSION: $Id: specwin.m,v 1.13 2007/08/31 17:40:08 hewitson Exp $ 0040 % 0041 % HISTORY: 30-01-07 M Hewitson 0042 % Creation 0043 % 0044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0045 0046 % w = specwin('Flattop', N, psll) - create a specwin Flattop window 0047 % with the prescribed psll. 0048 0049 ALGONAME = mfilename; 0050 VERSION = '$Id: specwin.m,v 1.13 2007/08/31 17:40:08 hewitson Exp $'; 0051 0052 if nargin == 0 0053 0054 % return list of windows 0055 w = {... 0056 'Rectangular', 'Welch', 'Bartlett', 'Hanning', 'Hamming',... 0057 'Nuttall3', 'Nuttall4', 'Nuttall3a', 'Nuttall3b', 'Nuttall4a',... 0058 'Nuttall4b', 'Nuttall4c', 'BH92', 'SFT3F', 'SFT3M', 'FTNI', 'SFT4F', 'SFT5F',... 0059 'SFT4M', 'FTHP', 'HFT70', 'FTSRS', 'SFT5M', 'HFT90D', 'HFT95', 'HFT116D',... 0060 'HFT144D', 'HFT169D', 'HFT196D', 'HFT223D', 'HFT248D'... 0061 }; 0062 0063 0064 0065 0066 %----------------------------------------------------- 0067 % create copy specwin 0068 elseif nargin == 1 0069 if isa(varargin{1}, 'org.apache.xerces.dom.DeferredElementImpl') 0070 w = fromxml(varargin{1}); 0071 elseif isa(varargin{1}, 'specwin') 0072 w = varargin{1}; 0073 elseif isstruct(varargin{1}) 0074 0075 w = class(varargin{1}, 'specwin'); 0076 return 0077 0078 elseif isa(varargin{1}, 'plist') 0079 0080 pl = varargin{1}; 0081 wname = find(pl, 'Name'); 0082 N = find(pl, 'N'); 0083 psll = find(pl, 'PSLL'); 0084 0085 switch wname 0086 case 'Kaiser' 0087 w = specwin(wname, N, psll); 0088 otherwise 0089 w = specwin(wname, N); 0090 end 0091 0092 elseif ischar(varargin{1}) 0093 0094 filename = varargin{1}; 0095 [path, name, ext, vers] = fileparts(filename); 0096 switch ext 0097 case '.mat' 0098 w = load(filename); 0099 case '.xml' 0100 w = xmlparse(specwin('Hanning', 1), filename); 0101 otherwise 0102 error('### Unknown file type.'); 0103 end 0104 0105 else 0106 error('### unknown constructor type for specwin object.'); 0107 end 0108 0109 elseif nargin == 2 0110 %----------------------------------------------------- 0111 % copy AO 0112 if isa(varargin{1}, 'specwin') 0113 w = varargin{1}; 0114 w.created = time; %sprintf('%s', datestr(now)); 0115 w.version = VERSION; 0116 %%%%%%%%%%% From DATABASE 0117 elseif isa(varargin{1}, 'database') 0118 0119 w = retrieve(varargin{1}, varargin{2:end}); 0120 %----------------------------------------------------- 0121 % create a particular type 0122 elseif ischar(varargin{1}) 0123 0124 % w = ltpda_specwin(varargin{1}, varargin{2}); 0125 w = get_window(varargin{1}, varargin{2}); 0126 w.created = time; %sprintf('%s', datestr(now)); 0127 w.version = VERSION; 0128 w = class(w, 'specwin'); 0129 0130 %----------------------------------------------------- 0131 % create from x-data 0132 else 0133 error('### unknown constructor for specwin object.') 0134 end 0135 %----------------------------------------------------- 0136 % Kaiser 0137 elseif nargin == 3 0138 0139 % w = ltpda_specwin(varargin{1}, varargin{2}, varargin{3}); 0140 w = get_window(varargin{1}, varargin{2}, varargin{3}); 0141 w.created = time; %sprintf('%s', datestr(now)); 0142 w.version = VERSION; 0143 w = class(w, 'specwin'); 0144 0145 else 0146 error('### Unknown number of constructor arguments.'); 0147 end 0148 0149 0150