【问题标题】:Converting the normalized angular frequency to frequency in Hz for an FIR filter将归一化角频率转换为 FIR 滤波器的频率(以 Hz 为单位)
【发布时间】: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


    【解决方案1】:

    freqz() 有一种形式,它采用采样率并以 Hz 为单位返回频率采样点,而不是弧度,所以不是...

    [h w]=freqz(x)
    f=[w*fs]/2
    

    ...你可以这样做:

    [h,f] = freqz(x,1,[],fs)
    

    如果我只是对您的代码进行更改,幅度响应图会显示它应该在的 -3dB 点。

    但您原始代码中的问题在于从弧度 (w) 到 Hz (f) 的转换;你用过:

    f=[w*fs]/2
    

    ...正确的转换是:

    f=[w*fs]/(2*pi)
    

    过滤愉快!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-02
      • 1970-01-01
      • 2019-01-19
      • 2021-11-05
      • 2017-07-04
      相关资源
      最近更新 更多