【问题标题】:matlab Band-pass Filter not workingmatlab带通滤波器不起作用
【发布时间】:2016-04-30 20:56:05
【问题描述】:

我尝试模拟噪声信号并对其进行过滤。信号混合了一些低频信号和一些随机噪声。我的目标是获得 14.8Hz 的信号。 我的带通带宽是 14.7Hz 到 14.9Hz。

function filteringTest

Hd = KaiserFilter;


Fs = 4000;                    % Sampling frequency
T = 1/Fs;                     % Sample time
L = 40000;                     % Length of signal
t = (0:L-1)*T;                % Time vector


r1 = 320;
r2 = 575;

y = 50*sin(2*pi*14.8*t) + r1*sin(2*pi*14.7*t) +  r2*sin(2*pi*15.1*t) + 10.1*rand(size(t));
yfilter = filter(Hd.Numerator,1,y);
plot(yfilter)



function Hd = KaiserFilter

Fs = 4000;  % Sampling Frequency

N    = 4096;     % Order
Fc1  = 14.7;     % First Cutoff Frequency
Fc2  = 14.9;     % Second Cutoff Frequency
flag = 'scale';  % Sampling Flag
Beta = 0.5;      % Window Parameter
% Create the window vector for the design algorithm.
win = kaiser(N+1, Beta);

% Calculate the coefficients using the FIR1 function.
b  = fir1(N, [Fc1 Fc2]/(Fs/2), 'bandpass', win, flag);
Hd = dfilt.dffir(b);

我的信号图像是:

过滤结果为:

当我尝试将过滤器顺序从 4096 增加到 32*4096 时,我得到以下结果:

为什么这个过滤器不能正常工作?我要改变我的过滤方法吗? 我应该怎么做才能得到14.8Hz的频率信号?

谢谢。

【问题讨论】:

    标签: matlab filter signals


    【解决方案1】:

    为什么你的采样率这么高?降低采样率并使用陷波滤波器取出选择性频率。我已经重写了你的代码的一些部分:

    Fs = 200;
    desiredFrequency = 14.8;
    [b,a] = NotchFilter(Fs, desiredFrequency)
    

    在过滤器定义中,你可以这样做:

    function [b,a] = NotchFilter(Fs,desiredFrequency)
    w = desiredFrequency/(Fs/2);
    [b,a] = iirnotch(w,w/400);
    

    现在执行过滤

    y_filter = filtfilt(b,a,y);
    desiredSignal = y-y_filter;
    plot(desiredSignal,'LineWidth',2); hold on; plot(y,'LineWidth',2)
    

    你会看到这样的东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-18
      • 2014-07-03
      • 2015-10-22
      相关资源
      最近更新 更多