FIR filter for ECG signal

18 次查看(过去 30 天)
Duy Nguyen
Duy Nguyen 2018-1-5
Hello everyone, I have a problem that I use FIR filter to eliminate the frequency 60Hz, but it does not work. Could you help me?
b=fir1(6,[0.118 0.122],'stop');
freqz(b,1);
dataIn=load('noisy_ECG.mat');
c=struct2cell(dataIn);
d=cell2mat(c);
dataOut=filter(b,1,d);
e=[0:9999];
plot(e,dataOut)

回答(1 个)

Star Strider
Star Strider 2018-1-5
One problem is that your filter is not long enough.
Try this:
b=fir1(64,[0.119 0.121],'stop');
freqz(b,1)
You may also want to refine it to create a more narrow stopband. Without knowing your sampling frequency, I cannot re-design it.
  2 个评论
Duy Nguyen
Duy Nguyen 2018-1-6
thank you, the sampling frequency is 1kHz. So I set cutoff frequency from 59Hz to 61Hz for 60Hz stopband. Could you help me to re-design this filter? thank you very much.
Star Strider
Star Strider 2018-1-6
编辑:Star Strider 2018-1-6
My pleasure.
Here you go:
Fs = 1E+3; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
b=fir1(48, [59.8 60.2]/Fn, 'stop');
freqz(b, 1, 2^16, Fs)
If you want a much steeper rolloff and much narrower notch, this works:
sb_frq = [58 59 61 62]; % Define Passband / Stopband Frequencies
mags = [1 0 1]; % Design Lowpass Filter
devs = [0.05 0.01 0.05]; % Allowed Deviations
[n,Wn,beta,ftype] = kaiserord(sb_frq,mags,devs,Fs); % Use Kaiser Window
n = n + rem(n,2); % Define Filter Order
b = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale'); % Design Filter
freqz(b, 1, 2^16, Fs)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Digital and Analog Filters 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by