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.15 2007/10/16 17:37:21 ingo 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() - 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.15 2007/10/16 17:37:21 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 ALGONAME = mfilename; 0053 VERSION = '$Id: specwin.m,v 1.15 2007/10/16 17:37:21 ingo Exp $'; 0054 0055 %%%%%%%%%%%%%%%%%%%% define parameter properties list %%%%%%%%%%%%%%%%%%%%% 0056 0057 function w = init() 0058 0059 w.name = 'no window'; 0060 w.alpha = -1; 0061 w.psll = -1; 0062 w.rov = -1; 0063 w.nenbw = -1; 0064 w.w3db = -1; 0065 w.flatness = -1; 0066 w.ws = -1; 0067 w.ws2 = -1; 0068 w.win = -1; 0069 w.created = time; 0070 w.version = VERSION; 0071 end 0072 0073 0074 0075 %%%%%%%%%% spw = specwin() %%%%%%%%%% 0076 if nargin == 0 0077 0078 w = init(); 0079 w = class(w, 'specwin'); 0080 0081 %----------------------------------------------------- 0082 % create copy specwin 0083 elseif nargin == 1 0084 if isa(varargin{1}, 'org.apache.xerces.dom.DeferredElementImpl') 0085 w = fromxml(varargin{1}); 0086 0087 %%%%%%%%%% spw = specwin(specwin) %%%%%%%%%% 0088 elseif isa(varargin{1}, 'specwin') 0089 w = varargin{1}; 0090 0091 %%%%%%%%%% spw = specwin(struct) %%%%%%%%%% 0092 elseif isstruct(varargin{1}) 0093 0094 %% created -> created-object 0095 if ismember('created', fieldnames(varargin{1})) 0096 if isstruct(varargin{1}.created) 0097 varargin{1}.created = time(varargin{1}.created); 0098 end 0099 end 0100 0101 w = class(varargin{1}, 'specwin'); 0102 return 0103 0104 %%%%%%%%%% spw = specwin(plist) %%%%%%%%%% 0105 elseif isa(varargin{1}, 'plist') 0106 0107 pl = varargin{1}; 0108 wname = find(pl, 'Name'); 0109 N = find(pl, 'N'); 0110 psll = find(pl, 'PSLL'); 0111 0112 switch wname 0113 case 'Kaiser' 0114 w = specwin(wname, N, psll); 0115 otherwise 0116 w = specwin(wname, N); 0117 end 0118 0119 elseif ischar(varargin{1}) 0120 0121 %%%%%%%%%% spw = specwin('Types') %%%%%%%%%% 0122 if strcmp(varargin{1}, 'Types') 0123 0124 % return list of windows 0125 w = {... 0126 'Rectangular', 'Welch', 'Bartlett', 'Hanning', 'Hamming',... 0127 'Nuttall3', 'Nuttall4', 'Nuttall3a', 'Nuttall3b', 'Nuttall4a',... 0128 'Nuttall4b', 'Nuttall4c', 'BH92', 'SFT3F', 'SFT3M', 'FTNI', 'SFT4F', 'SFT5F',... 0129 'SFT4M', 'FTHP', 'HFT70', 'FTSRS', 'SFT5M', 'HFT90D', 'HFT95', 'HFT116D',... 0130 'HFT144D', 'HFT169D', 'HFT196D', 'HFT223D', 'HFT248D'... 0131 }; 0132 0133 %%%%%%%%%% spw = specwin('foo.xml') %%%%%%%%%% 0134 else 0135 0136 filename = varargin{1}; 0137 [path, name, ext, vers] = fileparts(filename); 0138 switch ext 0139 case '.mat' 0140 w = load(filename); 0141 case '.xml' 0142 w = xmlparse(specwin('Hanning', 1), filename); 0143 otherwise 0144 error('### Unknown file type.'); 0145 end 0146 0147 end 0148 0149 else 0150 error('### unknown constructor type for specwin object.'); 0151 end 0152 0153 elseif nargin == 2 0154 %----------------------------------------------------- 0155 % copy AO 0156 if isa(varargin{1}, 'specwin') 0157 w = varargin{1}; 0158 w.created = time; %sprintf('%s', datestr(now)); 0159 w.version = VERSION; 0160 0161 %%%%%%%%%% spw = specwin(database, ...) %%%%%%%%%% 0162 elseif isa(varargin{1}, 'database') 0163 0164 w = retrieve(varargin{1}, varargin{2:end}); 0165 %----------------------------------------------------- 0166 % create a particular type 0167 elseif ischar(varargin{1}) 0168 0169 % w = ltpda_specwin(varargin{1}, varargin{2}); 0170 w = get_window(varargin{1}, varargin{2}); 0171 w.created = time; %sprintf('%s', datestr(now)); 0172 w.version = VERSION; 0173 w = class(w, 'specwin'); 0174 0175 %----------------------------------------------------- 0176 % create from x-data 0177 else 0178 error('### unknown constructor for specwin object.') 0179 end 0180 %----------------------------------------------------- 0181 % Kaiser 0182 elseif nargin == 3 0183 0184 % w = ltpda_specwin(varargin{1}, varargin{2}, varargin{3}); 0185 w = get_window(varargin{1}, varargin{2}, varargin{3}); 0186 w.created = time; %sprintf('%s', datestr(now)); 0187 w.version = VERSION; 0188 w = class(w, 'specwin'); 0189 0190 else 0191 error('### Unknown number of constructor arguments.'); 0192 end 0193 0194 end 0195