comparison m-toolbox/classes/@specwin/specwin.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % SPECWIN spectral window object class constructor.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SPECWIN spectral window object class constructor.
5 % Create a spectral window from libSpecWin.
6 %
7 % SUPERCLASSES: ltpda_nuo < ltpda_obj
8 %
9 % SPECWIN CONSTRUCTORS:
10 %
11 % w = specwin() - creates an empty object
12 % w = specwin(w) - copies a specwin object
13 % w = specwin('name') - creates the specified specwin object
14 % w = specwin('name', N) - creates a specwin object of a
15 % particular type and length.
16 % w = specwin('Kaiser', N, psll) - create a specwin Kaiser window
17 % with the prescribed psll.
18 %
19 % 'name' should be one of the following standard windows:
20 %
21 % Rectangular, Welch, Bartlett, Hanning, Hamming,
22 % Nuttall3, Nuttall4, Nuttall3a, Nuttall3b, Nuttall4a
23 % Nuttall4b, Nuttall4c, BH92, SFT3F, SFT3M, FTNI, SFT4F, SFT5F
24 % SFT4M, FTHP, HFT70, FTSRS, SFT5M, HFT90D, HFT95, HFT116D
25 % HFT144D, HFT169D, HFT196D, HFT223D, HFT248D
26 %
27 % VERSION: $Id: specwin.m,v 1.80 2011/05/24 16:19:00 mauro Exp $
28 %
29 % SEE ALSO: ltpda_obj, ltpda_nuo
30 %
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32
33 classdef (Hidden = true) specwin < ltpda_nuo
34
35 %------------------------------------------------
36 %---------- Private read-only Properties --------
37 %------------------------------------------------
38 properties (SetAccess = private)
39 type = ''; % name of window object
40 alpha = []; % alpha parameter for various window functions
41 psll = []; % peak sidelobe level
42 rov = []; % recommended overlap
43 nenbw = []; % normalised equivalent noise bandwidth
44 w3db = []; % 3 dB bandwidth in bins
45 flatness = []; % window flatness
46 levelorder = []; % levelling coefficient
47 skip = []; % number of bins to skip
48 end
49
50 properties (SetAccess = public)
51 len = 0; % window number of samples
52 end
53
54 properties (Dependent = true, SetAccess = private, Hidden = true)
55 win = []; % window samples
56 ws = 0; % sum of window values
57 ws2 = 0; % sum of squares of window values
58 end
59
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 % Check property setting %
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63
64 methods
65 function obj = set.win(obj, vals)
66 obj.len = length(vals);
67 end
68
69 function obj = set.ws(obj, ~)
70 end
71
72 function obj = set.ws2(obj, ~)
73 end
74
75 end
76
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 % Getters for constant properties %
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
81 methods
82 function win = get.win(obj)
83 win_name = sprintf('win_%s', lower(obj.type));
84 win = feval(win_name, obj, 'build');
85 end % win get method
86
87 function ws = get.ws(obj)
88 if obj.len ~= 0
89 % In this case, we need to calculate the property 'win' before
90 ws = sum(obj.win);
91 else
92 ws = 0;
93 end
94 end
95
96 function ws2 = get.ws2(obj)
97 if obj.len ~= 0
98 % In this case, we need to calculate the property 'win' before
99 ws2 = sum(obj.win .* obj.win);
100 else
101 ws2 = 0;
102 end
103 end
104 end
105
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 % Constructor %
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109 methods
110 function ww = specwin(varargin)
111
112 import utils.const.*
113 utils.helper.msg(msg.OMNAME, 'running %s/%s', mfilename('class'), mfilename);
114
115 %%%%%%%%%% Set dafault values %%%%%%%%%%
116
117 switch nargin
118 case 0
119 utils.helper.msg(msg.OPROC1, 'empty constructor');
120
121 case 1
122 if isa(varargin{1}, 'specwin')
123 utils.helper.msg(msg.OPROC1, 'copy constructor');
124 %%%%%%%%%% spw = specwin(specwin-object) %%%%%%%%%%
125 % copy existing specwin
126 ww = copy(varargin{1}, 1);
127
128 elseif isstruct(varargin{1})
129 %%%%%%%%%% spw = specwin(struct) %%%%%%%%%%
130 utils.helper.msg(msg.OPROC1, 'constructing from struct');
131 ww = fromStruct(ww, varargin{1});
132
133 elseif ischar(varargin{1})
134 %%%%%%%%%% spw = specwin(window-name) %%%%%%%%%%
135 utils.helper.msg(msg.OPROC1, 'constructing from string');
136 N = find(specwin.getInfo('specwin', 'From Window').plists, 'N');
137 ww = get_window(ww, varargin{1}, N);
138
139 else
140 error('### Unknown 1 argument constructor for specwin object.')
141 end
142
143 case 2
144 utils.helper.msg(msg.OPROC1, 'constructing type %s', varargin{1});
145 if ischar(varargin{1})
146 %%%%%%%%%% spw = specwin('Win_type', N) %%%%%%%%%%
147 ww = get_window(ww, varargin{1}, varargin{2});
148
149 elseif isa(varargin{1}, 'org.apache.xerces.dom.DeferredElementImpl') && ...
150 isa(varargin{2}, 'history')
151 %%%%%%%%%% obj = specwin(DOM node, history-objects) %%%%%%%%%%
152 ww = fromDom(ww, varargin{1}, varargin{2});
153
154 else
155 error('### Unknown 2 argument constructor for specwin object.')
156 end
157
158 case 3
159 utils.helper.msg(msg.OPROC1, 'constructing type %s', varargin{1});
160 %%%%%%%%%% spw = specwin('Kaiser', N, psll) %%%%%%%%%%
161 %%%%%%%%%% spw = specwin('levelledHanning', N, levelcoeff) %%%%%%%%%%
162 ww = get_window(ww, varargin{1}, varargin{2}, varargin{3});
163
164 otherwise
165 error('### Unknown number of constructor arguments');
166 end % End of constructor
167
168 end
169
170 end % End constructor
171
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 % Methods (Static, Public) %
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175
176 methods (Static = true)
177
178 function ww = getTypes()
179 ww = {...
180 'Rectangular', 'Welch', 'Bartlett', 'Hanning', 'Hamming',...
181 'Nuttall3', 'Nuttall4', 'Nuttall3a', 'Nuttall3b', 'Nuttall4a',...
182 'Nuttall4b', 'Nuttall4c', 'BH92', 'SFT3F', 'SFT3M', 'FTNI', 'SFT4F', 'SFT5F',...
183 'SFT4M', 'FTHP', 'HFT70', 'FTSRS', 'SFT5M', 'HFT90D', 'HFT95', 'HFT116D',...
184 'HFT144D', 'HFT169D', 'HFT196D', 'HFT223D', 'HFT248D', ...
185 'Kaiser', ...
186 'levelledHanning'...
187 };
188 end
189
190 function out = VEROUT()
191 out = '$Id: specwin.m,v 1.80 2011/05/24 16:19:00 mauro Exp $';
192 end
193
194 function ii = getInfo(varargin)
195 ii = utils.helper.generic_getInfo(varargin{:}, 'specwin');
196 end
197
198 function out = SETS()
199 out = {'Default', 'From Window'};
200 end
201
202 function out = getDefaultPlist(set)
203 switch lower(set)
204 case 'default'
205 out = plist();
206 case 'from window'
207 prefs = getappdata(0, 'LTPDApreferences');
208 out = plist('type', char(prefs.getMiscPrefs.getDefaultWindow), 'N', 0);
209 otherwise
210 error('### Unknown set [%s]', set);
211 end
212 end
213
214 function obj = initObjectWithSize(n,m)
215 obj = specwin.newarray([n m]);
216 end
217
218 end % End static methods
219
220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
221 % Methods (Static, Private) %
222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223
224 methods (Static = true, Access = private)
225
226 varargout = kaiser_alpha(varargin)
227 varargout = kaiser_flatness(varargin)
228 varargout = kaiser_nenbw(varargin)
229 varargout = kaiser_rov(varargin)
230 varargout = kaiser_w3db(varargin)
231
232 end % End static private methods
233
234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
235 % Methods (static, hidden) %
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237
238 methods (Static = true, Hidden = true)
239 varargout = loadobj(varargin)
240 varargout = update_struct(varargin)
241 end
242
243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 % Methods (public) %
245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246
247 methods (Hidden = true)
248 varargout = attachToDom(varargin)
249 end
250
251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252 % Methods (protected) %
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254
255 methods (Access = protected)
256 varargout = fromStruct(obj, obj_struct)
257 varargout = fromDom(varargin)
258
259 varargout = get_window(varargin)
260 varargout = win_bh92(varargin)
261 varargout = win_bartlett(varargin)
262 varargout = win_fthp(varargin)
263 varargout = win_ftni(varargin)
264 varargout = win_ftsrs(varargin)
265 varargout = win_hft116d(varargin)
266 varargout = win_hft144d(varargin)
267 varargout = win_hft169d(varargin)
268 varargout = win_hft196d(varargin)
269 varargout = win_hft223d(varargin)
270 varargout = win_hft248d(varargin)
271 varargout = win_hft70(varargin)
272 varargout = win_hft90d(varargin)
273 varargout = win_hft95(varargin)
274 varargout = win_hamming(varargin)
275 varargout = win_hanning(varargin)
276 varargout = win_nuttall3(varargin)
277 varargout = win_nuttall3a(varargin)
278 varargout = win_nuttall3b(varargin)
279 varargout = win_nuttall4(varargin)
280 varargout = win_nuttall4a(varargin)
281 varargout = win_nuttall4b(varargin)
282 varargout = win_nuttall4c(varargin)
283 varargout = win_rectangular(varargin)
284 varargout = win_sft3f(varargin)
285 varargout = win_sft3m(varargin)
286 varargout = win_sft4f(varargin)
287 varargout = win_sft4m(varargin)
288 varargout = win_sft5f(varargin)
289 varargout = win_sft5m(varargin)
290 varargout = win_welch(varargin)
291 varargout = win_kaiser(varargin)
292 varargout = win_levelledhanning(varargin)
293 end
294
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
296 % Methods (private) %
297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
298
299 methods (Access = private)
300 end
301
302 end % End classdef
303