-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetWindow.m
79 lines (70 loc) · 2.13 KB
/
getWindow.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
% FILE: getWindow.m
%
% FUNCTION: getWindow
%
% CALL: Wn = getWindow(Wn, order, wn_param)
%
% Returns a window of type Wn of length order
% DEFAULT: hanning window of length 16
%
% INPUTS:
% Wn - window type
% order - window length
% wn_param - window extra parameter
%
%
% OUTPUTS:
% Wn - window values
%
% USES: lanczos
%
% Author: Leonard-Gabriel Necula
% Created: December 24 2020
% Updated: January 18 2021
function Wn = getWindow(Wn, order, wn_param)
if nargin < 1
disp('Window type was not set. Set window type to hamming.');
Wn = 'hamming';
elseif isempty(Wn)
disp('Window type was left empty. Set window type to hamming.');
Wn = 'hamming';
end
if nargin < 2
disp('Window order was not set. Set window length to 16.');
order = 16;
elseif isempty(Wn)
disp('Window order was left empty. Set window length to 16.');
order = 16;
end
if checkType(Wn, [4, 7, 8, 9])
if nargin < 3
wn_param = setParamFor(Wn);
disp(['Filter window extra parameter was not set. ' ....
'Setting wn_param = ' num2str(wn_param)]);
elseif isempty(wn_param)
wn_param = setParamFor(Wn);
disp(['Filter window extra parameter was left empty. ' ....
'Setting wn_param = ' num2str(wn_param)]);
end
end
switch Wn
case 'boxcar'
Wn = boxcar(order);
case 'triang'
Wn = triang(order);
case 'blackman'
Wn = blackman(order);
case 'chebwin'
Wn = chebwin(order, wn_param);
case 'hamming'
Wn = hamming(order);
case 'hanning'
Wn = hanning(order);
case 'kaiser'
Wn = kaiser(order, wn_param);
case 'lanczos'
Wn = lanczos(order, wn_param);
case 'tukeywin'
Wn = tukeywin(order, wn_param);
end
end