FIR filter for ECG signal
    5 views (last 30 days)
  
       Show older comments
    

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)
0 Comments
Answers (1)
  Star Strider
      
      
 on 5 Jan 2018
        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 Comments
  Duy Nguyen
 on 6 Jan 2018
				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
      
      
 on 6 Jan 2018
				
      Edited: Star Strider
      
      
 on 6 Jan 2018
  
			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)
See Also
Categories
				Find more on Filter Design in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

