H (Z) Z bz+1 Z BZ + : % Define Sinusoidal Signal

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Adaptive Notch Filtering is a method of detecting the frequencies contained in a noisy signal.

The filter takes the standard second-order form


H ( z )=

z 2 +bz+ 1
z 2+ bz +2

The parameter controls the width of the notch in the filters frequency response, and can be set
as a constant. The b parameter is adjusted with the derivative of the filtered signal so that the
notch falls at the frequency of the signal.

It can be implemented in MatLab as follows:


a = 0.75;
mu = 0.05;
% Define sinusoidal signal
x = zeros(1,100);
for n = 0:499
x(n+1) = cos(n);
end
for n = 500:999
x(n+1) = cos(2*n);
end
wn = randn(1,1000);
for k = [0.25 0.75 2]
% Add noise to input
x = x+k*wn;
% initialize filter variables
freq = [];
fest = [];
b = zeros(1,1000);
y = zeros(1,1000);
% adaptive filter
for n = 3:1000
y(n) = x(n)+x(n-2)-a^2*y(n-2)+b(n)*(x(n-1)-a*y(n-1));
g(n) = x(n-1)-a*y(n-1);
b(n+1) = b(n)-mu*y(n)*g(n);
end
% convert pole location to notch frequency
for i = 1:length(b)
poles = roots([1 a*b(i) a^2]);
f = angle(poles);
fest = [fest abs(f(1))];
end

figure
subplot(2,1,1)
plot(fest)
title(['ANF for k =' num2str(k) ' a =' num2str(a)])
xlabel('time')
ylabel('estimated frequency')
subplot(2,1,2)
plot(b)
xlabel('time')
ylabel('tuning parameter')
end

Here, we start with a pure tone and add Gaussian random noise of amplitudes
0.25,0.75, and 2 times the signal amplitude to test the performance of the filter. For
k = 0.25 and k = 0.75, the filter is fairly accurate at predicting the frequency of the
signal. For k = 2, the behavior is erratic, which we would expect since the SNR is
now less than 1.

You might also like