-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhase_1.m
82 lines (62 loc) · 1.88 KB
/
Phase_1.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
80
81
82
%% Initializations
clear all; clc; close all;
M = 16; %
r = 89; %
L = 1.5; % controls the opening of the window, L close to 0 => rectangular window
beta = 5; % controls the opening of the window, beta close to 0 => rectangular window
alfa = 0.65; % controls the opening of the window, alfa close to 0 => rectangular window
w = cell(9,1);
w{1} = boxcar(M);
w{2} = triang(M);
w{3} = blackman(M);
w{4} = chebwin(M, r);
w{5} = hamming(M);
w{6} = hanning(M);
w{7} = kaiser(M, beta);
w{8} = lanczos(M, L);
w{9} = tukeywin(M, alfa);
% Norming
for i = 1:length(w)
w{i} = w{i}./sum(w{i});
end
titles = {'Rectangular Window Frequency response',
'Triangle Window Frequency response',
'Blackman Window Frequency response',
'Chebyshev Window Frequency response',
'Hamming Window Frequency response',
'Hanning Window Frequency response',
'Kaiser Window Frequency response',
'Lanczos Window Frequency response',
'Tukey Window Frequency response'};
titles_time = {'Rectangular Window',
'Triangle Window',
'Blackman Window',
'Chebyshev Window',
'Hamming Window',
'Hanning Window',
'Kaiser Window',
'Lanczos Window',
'Tukey Window'};
%% Time response
figure;
for i = 1 : length(titles)
subplot(3,3,i);
stem(0:M-1, w{i});
xlabel('Discrete Time');
xlim([0, M-1]);
title(titles_time{i});
end
%% GAIN
figure;
for i = 1 : length(titles)
subplot(3,3,i);
[H, omega] = freqz(w{i});
plotGain(H, omega, titles{i});
end
%% DB GAIN
figure;
for i = 1 : length(titles)
subplot(3,3,i);
[H, omega] = freqz(w{i});
plotGainDB(H, omega, strcat(titles{i}, ' in dB'));
end