MATLAB Answers

Remove the 50 Hz Hum from a Signal

6 views (last 30 days)
Ajira
Ajira on 11 Dec 2019
Answered: Star Strider on 11 Dec 2019
I have a signal which contains 40Hz and 50Hz values and it's FFT is like:
untitled.png
how can I remove 50Hz signal from it?
I tried second order filter but it getting worse: here is the filter code :
d = designfilt('bandstopiir','FilterOrder',2, ...
'HalfPowerFrequency1',49,'HalfPowerFrequency2',51, ...
'DesignMethod','butter','SampleRate',Fs);
and then: where u is the input signal,
filtering = filtfilt(d,u);
the result is:
untitled1.png
does anyone know where is the problem?
U which contains 40 and 50Hz signals is :
untitled3.png

  0 Comments

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 11 Dec 2019
The designfilt call designs a second-order Butterworth filter. It appears to be correct when I analyse it with freqz. Without seeing your data, it is not possible to determine what the problem is.
An alternative filter design is:
Fs = 900; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Wp = [48 52]/Fn; % Stopband Frequency (Normalised)
Ws = [0.9 1.1].*Wp; % Passband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 90; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp,'stop'); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^18, Fs) % Filter Bode Plot
set(subplot(2,1,1), 'XLim',[0 Fs/5]) % Optional
set(subplot(2,1,2), 'XLim',[0 Fs/5]) % Optional
filtering = filtfilt(sos, g, u); % Filter Signal
Provide the correct sampling frequency (I assume it is 900 Hz from the fft plot).

  0 Comments

Sign in to comment.

Sign in to answer this question.