www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/NotchFilterExample.m

    %% Notch filter
% This example shows how to use dsp.NotchPeakFilter as a notch filter with
% center frequency of 5000 Hz and a 3 dB bandwidth of 500 Hz.

%%
% *Note*: This example runs only in R2016b or later. If you are using an
% earlier release, replace each call to the function with the equivalent
% |step| syntax. For example, myObject(x) becomes step(myObject,x).

%%

h = dsp.NotchPeakFilter('CenterFrequency',5000,'Bandwidth',500);
hscope =  dsp.SpectrumAnalyzer('SampleRate',44100,...
    'PlotAsTwoSidedSpectrum',false,'SpectralAverages',50);
for i=1:5000
    y = h(randn(1024,1));
    hscope(y);
    if (i==2500)
        % Tune center frequency to 10000
        h.CenterFrequency = 10000;
    end
end
release(h)
release(hscope)