1 / 27

Designing Bandpass Filters

Designing Bandpass Filters.

nhu
Download Presentation

Designing Bandpass Filters

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Designing Bandpass Filters We will design several filters for the following normalized frequencies and desired frequency response. First, specify the desired frequency response point-wise, with 1.0 corresponding to half the sample rate. Plot the desired frequency response to make sure it is what we want (unnormalize the frequency axis).

  2. f = [0 .4 .4 .6 .6 1]; • H = [0 0 1 1 0 0]; • fs = 1000; % assumed sampling rate • fhz = f*fs/2; • plot(fhz,H) • title('Desired Frequency Response') • xlabel('Frequency (Hz)') • ylabel('Magnitude')

  3. The YULEWALK function lets you to specify a piecewise shape for the desired frequency response magnitude. It then finds an infinite-impulse response filter of the desired order that fits the frequency response in a least-squares sense. Use YULEWALK to compute the coefficients of an 8th order filter that will approximate our desired response. Plot the frequency response magnitude and compare it to the desired response.

  4. N = 8; % Order of the filter (number of poles and zeros). • [Bh,Ah] = yulewalk(N,f,H); % Working, please wait..... • n = 256; • hh = freqz(Bh,Ah,n); % compute complex frequency response • hy = abs(hh); % compute magnitude • ff = fs/(2*n) * (0:n-1); • plot(fhz,H,ff,hy) • title('Actual vs. Desired Frequency Response') • xlabel('Frequency (Hz)') • ylabel('Magnitude')

  5. Now let's design Butterworth and Chebyshev bandpass filters with the same passband (defined between 0.0 and 1.0). Here we compare all three frequency responses.

  6. N = 4; passband = [.4 .6]; ripple = .1; • [Bb,Ab] = butter(N, passband); • [Bc,Ac] = cheby1(N, ripple, passband); • h = [abs(hh) abs(freqz(Bb,Ab,n)) abs(freqz(Bc,Ac,n))]; • plot(ff,h) • legend({'YuleWalk','Butterworth','Chebyshev'}); • title('Filter Performance') • xlabel('Frequency (Hz)') • ylabel('Magnitude')

  7. Finally, look at the frequency response on a logarithmic decibel (dB) scale. plot(ff(2:n),20*log10(h(2:n,:))) • title('YuleWalk, Butterworth and Chebyshev filters') • xlabel('Frequency (Hz)') • ylabel('Magnitude in dB')

  8. Filter Design • This demonstration designs a filter with the Signal Processing Toolbox and applies it to a signal made up of harmonic components. • Here's an example of filtering with the Signal Processing Toolbox. First make a signal with three sinusoidal components (at frequencies of 5, 15, and 30 Hz).

  9. Fs = 100; • t = (1:100)/Fs; • s1 = sin(2*pi*t*5); s2=sin(2*pi*t*15); s3=sin(2*pi*t*30); • s = s1+s2+s3; • plot(t,s); • xlabel('Time (seconds)'); ylabel('Time waveform');

  10. To design a filter to keep the 15 Hz sinusoid and get rid of the 5 and 30 Hz sinusoids, we create an eighth order IIR filter with a passband from 10 to 20 Hz. Here is its frequency response. The filter was created with the ELLIP command.

  11. [b,a] = ellip(4,0.1,40,[10 20]*2/Fs); • [H,w] = freqz(b,a,512); • plot(w*Fs/(2*pi),abs(H)); • xlabel('Frequency (Hz)'); ylabel('Mag. of frequency response'); • grid;

  12. After filtering, we see the signal is a 15 Hz sinusoid, exactly as expected. sf = filter(b,a,s); • plot(t,sf); • xlabel('Time (seconds)'); • ylabel('Time waveform'); • axis([0 1 -1 1]);

  13. Finally, here is the frequency content of the signal before and after filtering. Notice the peaks at 5 and 30 Hz have been effectively eliminated. S = fft(s,512); • SF = fft(sf,512); • w = (0:255)/256*(Fs/2); • plot(w,abs([S(1:256)' SF(1:256)'])); • xlabel('Frequency (Hz)'); ylabel('Mag. of Fourier transform'); • grid; • legend({'before','after'})

More Related