Design of notch filter based on matlab

Table of contents

1. Theoretical basis

2. Core program

3. Simulation conclusion


1. Theoretical basis

       A notch filter refers to a filter that can quickly attenuate an input signal at a certain frequency to achieve a filtering effect that prevents the signal of this frequency from passing through. The notch filter is a kind of band-stop filter, but its stop band is very narrow, and the starting order must be above the second order (including the second order). The notch filter is a kind of band-stop filter, but its stop-band range is relatively narrow. Its function is to prevent the signal of a certain frequency f0 from reaching the output terminal from the input of the filter, or to greatly attenuate the f0 signal, so that there is almost no f0 signal component in the output signal, and signals other than f0 frequency can reach the output terminal smoothly .

     A notch filter is an infinite impulse response (IIR) digital filter that can be expressed by the following constant-coefficient linear difference equation:

        The frequency response can be roughly drawn from the zeros and poles of the transfer function. At the zero point, the frequency response has a minimum value; at the pole, the frequency response has a maximum value. Therefore, the zeros and poles can be configured according to the desired frequency response, and then the notch digital filter can be reverse-designed. Consider a special case, if the zero point is on the unit circle of the first quadrant, and the pole is on the radial direction close to the zero point within the unit circle. In order to prevent complex numbers from appearing in the filter coefficients, corresponding conjugate zeros and conjugate poles must be configured at the symmetrical positions of the fourth quadrant of the z plane. 

       Such a filter with zero and pole configurations is called a single-frequency notch filter, and a notch appears at frequency ωo. And set the pole at the distance of l-μ from the circle point in the radial direction of zero, the transfer function of the notch filter is:

       In formula (3), the smaller μ is, the closer the pole is to the unit circle, the deeper the frequency response curve is, and the narrower the width of the sag is. When it is necessary to eliminate narrow-band interference but cannot attenuate other frequencies, the notch filter is an ideal digital filter for removing narrow-band interference.

      When it is necessary to carry out notch filtering on several frequencies at the same time, the notch filters (3) of several individual frequencies can be connected in series according to (2).

2. Core program

...................................................
t=1:256;
t1=1:100;
t2=1:128;
x=sin(2*pi*50*t0/400)+0.5*sin(2*pi*100*t0/400);
x1=x(t);
y=filter(b,a,x1);
subplot(222); plot(x1);
title('Original waveform');
X=fft(x1);
subplot(223); plot(t2*400/256,abs(X(t2)));
xlabel('frequency in Hz'); ylabel('|H|'); axis([0, 200, 0, 150]);
title('Spectrum for original');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 50, 100, 150]); 
set(gca, 'YTickmode', 'manual', 'YTick', [50, 100]); grid
y=filter(b,a,x);
x1=y(t+7600);
X=fft(x1);
subplot(224); plot(t2*400/256,abs(X(t2)));
xlabel('frequency in Hz'); ylabel('|H|'); axis([0, 200, 0, 150]);
title('Spectrum after filter'); 
set(gca, 'XTickMode', 'manual', 'XTick', [0, 50, 100, 150]); 
set(gca, 'YTickmode', 'manual', 'YTick', [50, 100]); grid


figure(2);
subplot(611);plot(x(t1)); axis([1, 100, -1.5, 1.5]); ylabel('input x');
set(gca, 'YTickmode', 'manual', 'YTick', [-1,-0.5,0, 0.5,1]); grid
subplot(612);plot(y); axis([1, 100, -1.5, 1.5]); ylabel('first');
set(gca, 'YTickmode', 'manual', 'YTick', [-1,-0.5,0,0.5,1]); grid
subplot(613);plot(y); axis([401, 500, -1.5, 1.5]); ylabel('second');
set(gca, 'YTickmode', 'manual', 'YTick', [-1,-0.5,0, 0.5,1]); grid
subplot(614);plot(y); axis([1201, 1300, -1.0, 1.0]); ylabel('forth');
set(gca, 'YTickmode', 'manual', 'YTick', [-0.5,0, 0.5]); grid
subplot(615);plot(y); axis([2000, 2100, -1.0, 1.0]); ylabel('sixth');
set(gca, 'YTickmode', 'manual', 'YTick', [-0.5,0, 0.5]); grid
subplot(616);plot(y); axis([3601, 3700, -1.0, 1.0]); ylabel('tenth');
set(gca, 'YTickmode', 'manual', 'YTick', [-0.5,0, 0.5]); grid

figure(3);
subplot(611);plot(y); axis([4401, 4500, -1, 1]); ylabel('twelfth');
set(gca, 'YTickmode', 'manual', 'YTick', [-0.5,0, 0.5]); grid
subplot(612);plot(y); axis([5201, 5300, -1.0, 1.0]); ylabel('fourteenth');
set(gca, 'YTickmode', 'manual', 'YTick', [-0.5,0, 0.5]); grid
subplot(613);plot(y); axis([6001, 6100, -1.0, 1.0]); ylabel('sixteenth');
set(gca, 'YTickmode', 'manual', 'YTick', [-0.5,0, 0.5]); grid
subplot(212);plot(y); axis([7601, 7650, -1.0, 1.0]); ylabel('twentieth');
set(gca, 'YTickmode', 'manual', 'YTick', [-0.5, 0, 0.5]); grid
UP148

3. Simulation conclusion

 

 

Guess you like

Origin blog.csdn.net/ccsss22/article/details/130251612