在设计FIR滤波器时遇到点问题,

在设计FIR滤波器时遇到点问题,
clear all;
wlp=0.2*pi;wls=0.35*pi;wus=0.65*pi;wup=0.8*pi;
B=wls-wlp;
M=ceil(12*pi/B)-1;
wp=[(wls+wlp)/2/pi,(wus+wup)/2/pi];
hn=fir1(M,wp,'stop',blackman(M+1));
运行该程序会显示如下错误:
Error using ==> fir1 at 92
The window length must be the same as the filter length.
具体该怎么解决那?
运行了还是一样的!
Error using ==> fir1 at 92
The window length must be the same as the filter length.
Error in ==> ex723 at 6
hn=fir1(M,wp,'stop',blackman(M));
maigen 1年前 已收到1个回答 举报

wxx4670 幼苗

共回答了15个问题采纳率:100% 举报

先看下fir1中的一段解释
For filters with a gain other than zero at Fs/2, e.g., highpass
and bandstop filters, N must be even. Otherwise, N will be
incremented by one. In this case the window length should be
specified as N+2.
即高通、带阻滤波器的阶数应该控制为奇数,因为如果阶数为偶数,则在π点必有一零点,这对于高通带阻来说是不允许的,故取阶数为奇数,而你FIR1滤波器阶数为M+1阶,所以你的M必须为偶数,所以可以将程序改为
clear all;
clc
wlp=0.2*pi;wls=0.35*pi;wus=0.65*pi;wup=0.8*pi;
B=wls-wlp;
M=ceil(12*pi/B);
M=M+mod(M,2);
wp=[(wls+wlp)/2/pi,(wus+wup)/2/pi];
hn=fir1(M,wp,'stop',blackman(M+1));
freqz(hn)

1年前

2
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.027 s. - webmaster@yulucn.com