フィルターのクリア

Filtering of 60 Hz signal - not working

2 ビュー (過去 30 日間)
Chinwe Orie
Chinwe Orie 2019 年 10 月 6 日
コメント済み: Chinwe Orie 2019 年 10 月 7 日
Following the example "Remove the 60 Hz hum from a signal", I tried to run a butterworth filter in order to filter out multiples of 60 Hz (60, 120, 180, 240, etc.) from my signal. However, in some of my signals, the filter actually amplifies those frequencies which I am trying to filter out. Here is some my code. All help is appreciated:
multiples60 = 60:60:2500;
for v=1:length(multiples60)
halfpowerHz1 = multiples60(v) - 2;
halfpowerHz2 = multiples60(v) + 2;
d = designfilt('bandstopiir','FilterOrder',2, ...
'HalfPowerFrequency1',halfpowerHz1,'HalfPowerFrequency2',halfpowerHz2, ...
'DesignMethod','butter','SampleRate',Fs); %butterworth filter
if v==1
buttLoop = filtfilt(d,fsignal);
else
buttLoop = filtfilt(d,buttLoop);
end
end

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 10 月 6 日
Hi,
Here is what I have tested by changing in one point of your code and seen that it is working quite well now:
multiples60 = 60:60:2500;
for v=1:numel(multiples60)
halfpowerHz1 = multiples60(v) - 3;
halfpowerHz2 = multiples60(v) + 3;
d = designfilt('bandstopiir','FilterOrder', 2, ...
'HalfPowerFrequency1',halfpowerHz1,'HalfPowerFrequency2',halfpowerHz2, ...
'DesignMethod','butter', 'SampleRate',Fs); %butterworth filter
if v==1
buttLoop = filtfilt(d,fsignal);
else
buttLoop = filtfilt(d,buttLoop);
end
end
L = length(fsignal);
N = 4*2048; % block size
f = Fs/2*linspace(0,1, N/2+1);
Y = fft(buttLoop, N)/L;
plot(f, Y(1:N/2+1)), grid on
Good luck
  1 件のコメント
Chinwe Orie
Chinwe Orie 2019 年 10 月 7 日
Thank you! It works, but I'm wondering why just changing the code from 'length(multiples60)' to 'numel(multiplies60)' and changing the number substraction from -2 to -3 would cause it to work? Is there a chacne that -3 might be too high?

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by