Mercurial > hg > ltpda
comparison m-toolbox/classes/@specwin/get_window.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 % GET_WINDOW returns the required window function as a structure. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: GET_WINDOW returns the required window function as a structure. | |
5 % | |
6 % CALL: objs = get_window(objs, name, N); % For standard windows | |
7 % objs = get_window(objs, name, N, PSLL); % For Kaiser windows | |
8 % objs = get_window(objs, name, N, levelCoeff); % For levelled-Hann windows | |
9 % | |
10 % VERSION: $Id: get_window.m,v 1.8 2011/05/24 16:05:05 mauro Exp $ | |
11 % | |
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
13 | |
14 function w = get_window(varargin) | |
15 | |
16 PSLL = []; | |
17 | |
18 % Check inputs | |
19 n_args = nargin; | |
20 if n_args > 4 || n_args < 3 | |
21 error('### Incorrect inputs.'); | |
22 end | |
23 | |
24 % Get inputs | |
25 w = varargin{1}; | |
26 name = varargin{2}; | |
27 N = varargin{3}; | |
28 if n_args == 4 | |
29 PSLL = varargin{4}; | |
30 end | |
31 | |
32 % Get window | |
33 if isempty(PSLL) | |
34 | |
35 % Check for 'Kaiser' window | |
36 if strcmpi(name, 'Kaiser') | |
37 error('### The ''Kaiser'' window needed the length of the window and PSLL as an input'); | |
38 end | |
39 | |
40 % Check for 'levelledHanning' window | |
41 if strcmpi(name, 'levelledHanning') | |
42 error('### The ''levelledHanning'' window needed the levelling coefficient as an input'); | |
43 end | |
44 | |
45 % get standard window | |
46 | |
47 win_name = sprintf('win_%s', lower(name)); | |
48 try | |
49 w = feval(win_name, w, 'define', N); | |
50 catch ME | |
51 if strcmp(ME.identifier, 'MATLAB:UndefinedFunction') | |
52 error('\n### Your window [%s] is not a supported window.\n### Please type >> specwin.getTypes to see all supported windows.', name); | |
53 else | |
54 rethrow(ME); | |
55 end | |
56 end | |
57 | |
58 else | |
59 | |
60 if strcmpi(name, 'Kaiser') | |
61 % Deal with Kaiser | |
62 win_name = sprintf('win_%s', lower(name)); | |
63 w = feval(win_name, w, 'define', N, PSLL); | |
64 elseif strcmpi(name, 'levelledHanning') | |
65 % Deal with levelledHann window | |
66 win_name = sprintf('win_%s', lower(name)); | |
67 levelCoef = PSLL; | |
68 w = feval(win_name, w, 'define', N, levelCoef); | |
69 else | |
70 error('\n### Your window [%s] is not a supported 2-inputs window.\n### Please type >> specwin.getTypes to see all supported windows.', name); | |
71 end | |
72 | |
73 end | |
74 end | |
75 |