当前位置:首页 > DSP实验报告6 用窗函数法设计FIR滤波器 - 图文
plot(m,pha) hold on n=0:7; x=zeros(8); plot(n,x,'-') hold off
axis([0 3.15 -4 4]) xlabel('频率(rad)') ylabel('相位(rad)') title('相频特性')
subplot(2,2,4) plot(m,mag) axis([0 3.15 0 1.5]) xlabel('频率W(rad)') ylabel('幅值') title('幅频特性') text(0.9,1.2,string)
实验要求:
1. 修改理想低通程序为理想高通、带通、带阻的程序,重新进行实验,注意高通、带阻滤波器的情况下,N的取值有何限制? 2. 直接调用FIR1函数,重新进行实验;
3. 观察不同窗函数对滤波特性即对阻带衰减的影响,另外观察窗函数的长度N对过渡带宽的影响。
用窗函数法设计FIR高通滤波器程序
clear all; N=17;
Wc=pi/4;%理想低通滤波器设计(怎样设计理想高通、带通、带阻滤波器?) alpha=(N-1)/2;
n=[0:(N-1)];
m=n-alpha+eps;%hd=sin(Wc*m)./(pi*m); %理想低通的单位脉冲响应 hd= sin(pi*m)./(pi*m)-sin(Wc*m)./(pi*m); %理想高通的单位脉冲响应 B=boxcar(N);%矩形窗
string=['Boxcar ','N=',num2str(N)]; h=hd.*(B)'; %加窗截取
%以上过程可直接调用FIR1实现 %wc=Wc/pi;%频率归一化 %h=fir1(N-1,wc,boxcar(N));
[H,m]=freqz(h,[1],1024,'whole'); %频率响应 mag=abs(H);
db=20*log10((mag+eps)/max(mag)); pha=angle(H); subplot(2,2,1) n=0:N-1; stem(n,h,'.')
axis([0 N-1 -0.1 0.3]) hold on n=0:N-1; x=zeros(N); plot(n,x,'-') hold off xlabel('n') ylabel('h(n)')
title('实际高通滤波器的h(n)')
text(0.3*N,0.27,string) subplot(2,2,2) plot(m/pi,db) axis([0 1 -100 0])
xlabel('w/pi') ylabel('dB')
title('副频衰减特性')
grid on
subplot(2,2,3) plot(m,pha) hold on n=0:7; x=zeros(8); plot(n,x,'-' hold off
axis([0 3.15 -4 4]) xlabel('频率(rad)') ylabel('相位(rad)') title('相频特性')
subplot(2,2,4) plot(m,mag)
axis([0 3.15 0 1.5]) xlabel('频率W(rad)') ylabel('幅值') title('幅频特性')
text(0.9,1.2,string)
共分享92篇相关文档