擺脫這些諧波的最簡單的方法是簡單的低通濾波器...這將擺脫所有頻率成分的分界之上的。這不再是一個陷波濾波器,像你這樣的表現,但它肯定會擺脫高大的諧波:
%% lowpass IIR filter example
fs_Hz = 1; %your sample rate appears to be 1 Hz
fund_Hz = 1/40; %this is your fundamental
cutoff_Hz = 1.5*fund_Hz; %choose cutoff
[b,a] = butter(3,fund_Hz/(fs_Hz/2)); %lowpass by default
y = filter(b,a,s13); %apply filter
如果一個低通濾波器是太多了過濾,那麼它聽起來像你的問題是,你不不知道如何做一個多陷波器。沒關係。您可以選擇通過應用一系列的缺口的缺口我們您的諧波濾波器一後的,其他的...
%% apply IIR notch filters in series
fs_Hz = 1; %your sample rate
fund_Hz =1/40; %your fundamental frequency
y = x; %initialize your output
for Iharm = 3:2:7 %will do 3rd, 5th, 7th
[b, a] = ellip(6,0.5,20,[(Iharm-0.3) (Iharm+0.3)]*fund_Hz/(fs_hz/2),'stop');
y = filter(b,a,y); %apply the filter onto the previous output
end
最後,如果你想要做的這一切作爲一個過濾器,你會需要更復雜的過濾器。你可以根據極點和零點來設計你自己的(如果這是一個類項目,這聽起來可能就是這個意思)。或者,您可以使用其中一個過濾器設計命令,允許您輸入任意響應。如果您想使用IIR濾波器(與FIR濾波器相反),請查看yulewalk
命令。你會使用它是這樣的(我沒有在使用了一段時間,所以這可能不是正確的...
%% yulewalk example
f_Hz = 1; %your sample rate
f_fund_Hz = 1/40; %your fundamental
%define desired response at different frequencies
w = 0.3; %width of each notch
f_Hz = [3-w 3 3+w 5-w 5 5+w 7-w 7 7+w]*f_fund_Hz; %3rd, 5th, 7th harmonics
resp = [ 1 0 1 1 0 1 1 0 1 ]; %notch each harmonic
f_Hz = [0; f_Hz(:); fs/2]; %must start at 0 Hz and end at Nyquist
resp = [1; resp(:); 1]; %add start and end points
%create and apply the filter
N = 3*3; %filter order...play with this...N=3 per notch?
[b,a]=yulewalk(N,f_Hz/(fs_Hz/2),resp); %create filter
y = filter(b,a,x); %apply filter
我真的很感謝你的努力,你解決了我的問題的最好辦法。最好的祝福 –