一、实验目的 1.掌握FIR 滤波器设计的各种基本方法 2.了解数字微分器的频域特性 3.学会用窗函数法设计数字微分器 二、实验原理 在连续时间系统中,对信号x(t)的导数的拉普拉斯变换是

三、实验内容 1. 复习课本第七章有关内容,对窗函数法,频率采样法设计FIR 滤波器有清晰的了解。
2. 试用海明窗和布莱克曼窗设计一个6 阶的微分器,比较他们的幅频特性和理想情况的 差异。
3. 用频率采样法重新设计上述的微分器。
4. 当微分器的阶数取N=16 时,重复实验内容3。 参考流程图 1. 窗函数法

2. 频率采样法

四、实验报告要求 1.简述实验目的及原理。 2.整理好经过运行并证明是正确的实验程序并加上注释。绘出相应的图形。
%hamming窗
M=21;alpha=(M-1)/2;n=0:M-1;
hd=(cos(pi*(n-alpha)))./(n-alpha);hd(alpha+1)=0;
w_ham=(hamming(M))'; h=hd.*w_ham; [Hr,w,P,L]=Hr_Type3(h);
%plots
subplot(221);stem(n,hd);
title('Ideal Impulse Response') axis([-1 M -1.2 1.2]);
xlabel('n');ylabel('hd(n)') subplot(222);stem(n,w_ham);
title('Hamming Window') axis([-1 M 0 1.2]);xlabel('n');ylabel('w(n)')
subplot(223);stem(n,h);
title('Actual Impulse Response') axis([-1 M -1.2 1.2]);xlabel('n');ylabel('h(n)')
subplot(224);plot(w/pi,Hr/pi);
title('Amplitude Response');grid;
axis([0 1 0 1]);xlabel('frenquency in pi units');ylabel('slope in pi units');
子函数:function [Hr,w,c,L] = Hr_Type3(h);
% Computes Amplitude response of Type-3 LP FIR filter
% - - - - - - - - - - - - - - - - ---
% [Hr,w,c,L] = Hr_Type3(h)
% Hr = Amplitude Response
% w = frequencies between [0 pi] over which Hr is computed
% c = Type-3 LP filter coefficients
% L = Order of Hr
% h = Type-3 LP impulse response
%
M = length(h);
L = (M-1)/2;
c = [2*h(L+1:-1:1)];
n=[0:1:L];
w = [0:1:500]'*pi/500;
Hr = sin(w*n)*c';
%blackman窗
M=21;alpha=(M-1)/2;n=0:M-1;
hd=(cos(pi*(n-alpha)))./(n-alpha);
hd(alpha+1)=0; w_black=(blackman(M))';
h=hd.*w_black; [Hr,w,P,L]=Hr_Type3(h);
%plots figure;
subplot(221);stem(n,hd);
title('Ideal Impulse Response') axis([-1 M -1.2 1.2]);
xlabel('n');ylabel('hd(n)')
subplot(222);
stem(n,w_black);
title('Blackman Window') axis([-1 M 0 1.2]);xlabel('n');ylabel('w(n)')
subplot(223);
stem(n,h);
title('Actual Impulse Response')
axis([-1 M -1.2 1.2]);xlabel('n');ylabel('h(n)')
subplot(224);plot(w/pi,Hr/pi);
title('Amplitude Response');grid;
axis([0 1 0 1]);xlabel('frenquency in pi units');ylabel('slope in pi units');
%频率采样法
M=33;alpha=(M-1)/2;
Dw=2*pi/M;l=0:M-1;wl=Dw*l;
k1=0:floor((M-1)/2);k2=floor((M-1)/2)+1:M-1;
Hrs=[j*Dw*k1,-j*Dw*(M-k2)];
angH=[-alpha*Dw*k1,alpha*Dw*(M-k2)];
H=Hrs.*exp(j*angH);h=real(ifft(H,M));
[Hr,ww,a,P]=Hr_Type3(h);
%plots figure;
subplot(211);stem(0:M-1,h);
title('Actual Impulse Response') axis([-1 M -0.5 1.5]);
xlabel('n');ylabel('h(n)') subplot(212);
plot(ww/pi,Hr/pi);title('Amplitude Response');grid;
axis([0 1 -0.5 1.5]);xlabel('frenquency in pi units');
ylabel('slope in pi units');