ディジタルフィルタのインパルス応答

clear; close all;

wc = pi/8;
T = 1;
N=61;
l = (N-1)/2;
ks = 1:N;
h1 = [];
h2 = [];
h3 = [];
h4 = [];
w0 = pi/2;
for kprime = ks
    k = kprime-1;
    hk1 = wc*T/pi*sin((k-l)*wc*T)/(k-l)/wc/T;
    h1(end+1) = hk1;
    hk2 = -wc*T/pi*sin((k-l)*wc*T)/(k-l)/wc/T;
    h2(end+1) = hk2;
    hk3 = 2*wc*T/pi*sin((k-l)*wc*T)/(k-l)/wc/T*cos(k-l)*w0*T;
    h3(end+1) = hk3;
    hk4 = -2*wc*T/pi*sin((k-l)*wc*T)/(k-l)/wc/T*cos(k-l)*w0*T;
    h4(end+1) = hk4;
end
h2(l+1) = 1-wc*T/pi;
h4(l+1) = 1-2*wc*T/pi;

subplot(231);
stem(ks, h1 ,'o-','DisplayName','Low pass filter');
legend();
subplot(232);
stem(ks, h2 ,'o-','DisplayName','High pass filter');
legend();
subplot(233);
stem(ks, h1+h2 ,'o-','DisplayName','LPF+HPF');
legend();

subplot(234);
stem(ks, h3 ,'o-','DisplayName','Band pass filter');
legend();
subplot(235);
stem(ks, h4 ,'o-', 'DisplayName','Band eliminate filter');
legend();
subplot(236);
stem(ks, h3+h4 ,'o-', 'DisplayName','BPF+BEF');
legend();
big;