方法一
clear all;
close all;
M1=21;
wc=0.5*pi;
a=(M1-1)/2;
n=[0:1:(M1-1)];
m=n-a+eps;
hd1=sin(wc*m)./(pi*m);
wn1=boxcar(M1);
hn1=hd1.*wn1';
[hw1,w1]=freqz(hn1,1);
M2=21;
n=[0:1:(M2-1)];
a=(M2-1)/2;
m=n-a+eps;
hd2=sin(wc*m)./(pi*m);
wn2=Hanning(M2);
hn2=hd2.*wn2';
[hw2,w2]=freqz(hn2,1);
subplot(321);
stem(hn1);
subplot(322);
stem(hn2);
subplot(323);
plot(w1/pi,20*log10(abs(hw1)/abs(hw1(1))));
subplot(324);
plot(w2/pi,20*log10(abs(hw2)/abs(hw2(1))));
subplot(325);
plot(w1,unwrap(angle(hw1)));
subplot(326);
plot(w2,unwrap(angle(hw2)));
方法二
clear all;
close all;
M1=21;
wc=0.5*pi;
a=(M1-1)/2;
n=[0:1:(M1-1)];
m=n-a+eps;
hd1=sin(wc*m)./(pi*m);
wn1=boxcar(M1);
hn1=hd1.*wn1';
freqz(hn1,1);
figure;
M2=21;
n=[0:1:(M2-1)];
a=(M2-1)/2;
m=n-a+eps;
hd2=sin(wc*m)./(pi*m);
wn2=Hanning(M2);
hn2=hd2.*wn2';
freqz(hn2,1);
因篇幅问题不能全部显示,请点此查看更多更全内容