给你个参考例子
wc=(400/1000)*pi; %求截止频率
w1=boxcar(81); %窗函数
w2=triang(81);
w3=hamming(81);
w4=hanning(81);
w5=bartlett(81);
w6=blackman(81);
w7=chebwin(81,30);
w8=kaiser(81,7.856);
n=1:1:81;
hd=sin(wc*(n-41))./(pi*(n-41)); %求h(d)
hd(41)=wc/pi;
h1=hd.*w1'; %加窗
h2=hd.*w2';
h3=hd.*w3';
h4=hd.*w4';
h5=hd.*w5';
h6=hd.*w6';
h7=hd.*w7';
h8=hd.*w8';
[mag1,rad]=freqz(h1); %求幅频特性曲线
[mag2,rad]=freqz(h2);
[mag3,rad]=freqz(h3);
[mag4,rad]=freqz(h4);
[mag5,rad]=freqz(h5);
[mag6,rad]=freqz(h6);
[mag7,rad]=freqz(h7);
[mag8,rad]=freqz(h8);
figure(1); %画幅频特性曲线
plot(rad,20*log10(abs(mag1)));
xlabel('Normalized Frequency(rad)');
ylabel('Normaliaed Magnitude(dB)');
axis([0,3,-80,0]);
title('利用矩形窗设计的数字滤波器');
grid on;
figure(2);
plot(rad,20*log10(abs(mag2)));
xlabel('Normalized Frequency(rad)');
ylabel('Normaliaed Magnitude(dB)');
axis([0,3,-80,0]);
title('利用三角窗设计的数字滤波器');
grid on;
figure(3);
plot(rad,20*log10(abs(mag3)));
xlabel('Normalized Frequency(rad)');
ylabel('Normaliaed Magnitude(dB)');
axis([0,3,-80,0]);
title('利用海明设计的数字滤波器');
grid on;
figure(4);
plot(rad,20*log10(abs(mag4)));
xlabel('Normalized Frequency(rad)');
ylabel('Normaliaed Magnitude(dB)');
axis([0,3,-80,0]);
title('利用汉宁窗设计的数字滤波器');
grid on;
figure(5);
plot(rad,20*log10(abs(mag5)));
xlabel('Normalized Frequency(rad)');
ylabel('Normaliaed Magnitude(dB)');
axis([0,3,-80,0]);
title('利用巴特里特窗设计的数字滤波器');
grid on;
figure(6);
plot(rad,20*log10(abs(mag6)));
xlabel('Normalized Frequency(rad)');
ylabel('Normaliaed Magnitude(dB)');
axis([0,3,-100,0]);
title('利用布拉克曼窗设计的数字滤波器');
grid on;
figure(7);
plot(rad,20*log10(abs(mag7)));
xlabel('Normalized Frequency(rad)');
ylabel('Normaliaed Magnitude(dB)');
axis([0,3,-100,0]);
title('利用切比雪夫窗设计的数字滤波器');
grid on;
figure(8);
plot(rad,20*log10(abs(mag8)));
xlabel('Normalized Frequency(rad)');
ylabel('Normaliaed Magnitude(dB)');axis([0,3,-100,0]);
title('利用凯塞窗设计的数字滤波器');
grid on;