-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
66 lines (56 loc) · 1.58 KB
/
main.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
clc, clearvars, close all
% Specifications
Fs = 8e3;
% FIR Filters
lowpass = LowpassFilter(70, Fs, 700, 1000, 1);
highpass = HighpassFilter(50, Fs, 1600, 1800, 0);
bandpass = BandpassFilter(32, Fs, 750, 800, 1800, 1850, 0);
bandstop = BandstopFilter(30, Fs, 700, 800, 1800, 1900, 0);
peak = PeakFilter(60, Fs, 2000, 1);
notch = NotchFilter(60, Fs, 2000, 1);
% Frequency response
[h_lp, w_lp] = freqz(lowpass);
[h_hp, w_hp] = freqz(highpass);
[h_bp, w_bp] = freqz(bandpass);
[h_bs, w_bs] = freqz(bandstop);
[h_p, w_p] = freqz(peak);
[h_n, w_n] = freqz(notch);
% Plot frequency response of each filter
figure;
subplot(3,2,1)
plot(w_lp*Fs/2/pi, abs(h_lp)/max(abs(h_lp)), 'LineWidth', 1.5)
grid on
xlabel('f(Hz)')
ylabel('|H_{lp}(j\omega)|')
title('Lowpass Filter')
subplot(3,2,2)
plot(w_hp*Fs/2/pi, abs(h_hp)/max(abs(h_hp)), 'LineWidth', 1.5)
grid on
xlabel('f(Hz)')
ylabel('|H_{hp}(j\omega)|')
title('Highpass Filter')
subplot(3,2,3)
plot(w_bp*Fs/2/pi, abs(h_bp)/max(abs(h_bp)), 'LineWidth', 1.5)
grid on
xlabel('f(Hz)')
ylabel('|H_{bp}(j\omega)|')
title('Bandpass Filter')
subplot(3,2,4)
plot(w_bs*Fs/2/pi, abs(h_bs)/max(abs(h_bs)), 'LineWidth', 1.5)
grid on
xlabel('f(Hz)')
ylabel('|H_{bs}(j\omega)|')
title('Bandstop Filter')
subplot(3,2,5)
plot(w_p*Fs/2/pi, abs(h_p)/max(abs(h_p)), 'LineWidth', 1.5)
grid on
xlabel('f(Hz)')
ylabel('|H_{p}(j\omega)|')
title('Peak Filter')
subplot(3,2,6)
plot(w_n*Fs/2/pi, abs(h_n)/max(abs(h_n)), 'LineWidth', 1.5)
grid on
xlabel('f(Hz)')
ylabel('|H_{n}(j\omega)|')
title('Notch Filter')
suptitle('FIR Filters')