在设计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 ==> f
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 09:47:23
在设计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 ==> f
在设计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));
在设计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 ==> f
先看下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)