【发布时间】:2018-10-02 01:45:41
【问题描述】:
我正在使用 Kaiser 窗口在 Matlab 中设计 FIR 滤波器。
我需要将滤波器的幅度和相位响应以 x 轴作为赫兹的频率来绘制,而不是用归一化的角频率来绘制它们。这样做,返回的 wn 等于 0.34(由kaiserord() 返回),当我将其转换为赫兹时,它会根据需要给我 42.5 Hz。
我的问题是,当我绘制幅度响应时,-3dB 点出现在 100 Hz 以上的频率上,这意味着截止频率不等于 42.5 Hz。 那么我的代码有什么问题?这是代码(带有所需的过滤器规格):
fs=250;
fcuts=[40 45]; % passband and stopband frequencies
mags=[1 0]; % The required filter amplitude in these bands (Absolute value not in dB)
devs=[0.23 0.23];% Passband and stopband ripples (Absolute value not in dB)
[N,wn,beta,ftype]=kaiserord(fcuts,mags,devs,fs); % using kaiser window for designing the fir filter . This function will return the cuttoff freq. , order of the filter , filter type and betta according to the design specs.
x=fir1(N,wn,ftype,kaiser(N+1,beta)); % designing the corresponding fir filter ( note that fir1 takes an even filter order so we wrote N+1)
[h w]=freqz(x)
f=[w*fs]/2
subplot(2,1,1);
plot(f,20*log10(abs(h))); % we will use 20log10() for ploting the mag. response in dB . abs(h) is the magnitude response
title('magnitude response')
grid on % turning the grid on
set(gca,'YTick',-80:5:0)
xlabel('Frequency(Hz)')
ylabel('Magnitude(dB)')
subplot(2,1,2);
plot(f,rad2deg(angle(h)));
title('phase response')
grid on
%set(gca,'YTick',-100:5:0)
xlabel('Frequency(Hz)')
ylabel('phase(degree)')
编辑:wn=0.34 是否首先对应于 42.5 Hz? 我算对了吗?
【问题讨论】:
标签: matlab filtering frequency