Filter löschen
Filter löschen

Weird issues with 60 Hz noise filtering

1 Ansicht (letzte 30 Tage)
Anand Kulkarni
Anand Kulkarni am 10 Jul. 2018
Bearbeitet: Anand Kulkarni am 10 Jul. 2018
I am trying to evaluate the performance of a notch filter (for eliminating 60Hz noise) designed in Matlab. I am doing so by calculating spectrogram of the signal before and after filtering and then comparing the 'power' in the ~60 Hz bin of the spectrogram. Here is the code that I am using for that.
% taking spectrogram of the original signal
[s,f,t,~]=spectrogram(vdata(:,i+1),hamming(668),167,668,fs);
f(relrow) % this is around 60 Hz
s=abs(s);
s=log(s);
fi_pre=medfilt1(s(relrow,:),11); % median filtering the spectrogram row to smooth it
figure
ax1=subplot(3,1,1);
plot(t,fi_pre,'k-')
xlabel('Median filter applied to 60Hz bin of spectrogram of ORIGINAL signal','fontsize',12,'fontweight','bold')
d = designfilt('bandstopiir','FilterOrder',2, ...
'HalfPowerFrequency1',59,'HalfPowerFrequency2',61, ...
'DesignMethod','butter','SampleRate',fs);
filtv = filtfilt(d,vdata(:,i+1));
% taking spectrogram of the filtered signal
[s,f,t,~]=spectrogram(filtv,hamming(668),167,668,fs);
s=abs(s);
s=log(s);
ax2=subplot(3,1,2);
fi=medfilt1(s(relrow,:),11);
plot(t,fi,'r-')
xlabel('Median filter applied to 60Hz bin of spectrogram of FILTERED signal','fontsize',12,'fontweight','bold')
ax3=subplot(3,1,3);
plot(t,fi_pre-fi,'r-')
hold(ax3,'on')
xlims=xlim(ax3);
plot(ax3,xlims,[0,0])
xlabel('First plot minus second plot','fontsize',12,'fontweight','bold')
Here is output of the code:
My expectation was that the 'power' values in the spectrogram of the filtered signal would be lower, but they are actually higher (note that the third plot is mostly below zero during the first half). The only times when they are lower are those when the original signal has 60 Hz noise. I find this strange. Why do you think this is happening? p.s. Its possible that my expectation or my method of evaluating a filter's performance is improper. I may be missing something very obvious to signal processing geeks. For the record this is how the signal looks like:

Antworten (0)

Tags

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by