Experiment 5 - FIR Filter
Experiment 5 - FIR Filter
Experiment 5 - FIR Filter
Experiment 5
Finite Impulse Response (FIR) Filter
OBJECTIVES:
1. Build and apply simple non-recursive filters
2. Plot the frequency and phase response and pole-zero response of a filter.
Digital filters
Classified into one of two basic forms, according to how they respond to an unit impulse:
Finite impulse response, or FIR, filters express each output sample as a weighted sum of
the last N inputs, where N is the order of the filter. Since they do not use feedback, they
are inherently stable.
Infinite impulse response, or IIR, filters are the digital counterpart to analog filters. Such
a filter contains internal state, and the output and the next internal state are determine
by a linear combination of the previous inputs and outputs.
The two uses of filters are:
1. Signal separation. Signal separation is needed when a signal has been contaminated with
interference, noise, or other signals.
2. Signal restoration. Signal restoration is used when a signal has been distorted in some ways.
Characterization of FIR Filters
For a causal discrete-time FIR filter of order N, each value of the output sequence is a weighted
sum of the most recent input values:
y[n] = b0x[n]+b1x[n-1]+ . . . +bNx[n-N]
where:
x[n] is the input signal,
y[n] is the output signal,
bi are the filter coefficients, also known as tap weights, and
N is the filter order – an Nth-order filter has (N + 1) terms on the right-hand side.
These are commonly referred to as taps (the number of inputs).
An FIR filter’s frequency response has no poles, only zeros.
1|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Types of Filters
Lowpass filter – allows the passage of low frequencies and attenuates higher
frequencies with respect to cutoff frequency (fcl).
Highpass filter – allows the passage of high frequencies and attenuates lower
frequencies with respect to cutoff frequency (fcu).
Bandpass filter – allows the passage of a band of frequencies between the lower and
upper cutoff frequencies.
Bandstop filter (band elimination filter or band reject filter) – rejects a band of
frequencies between the lower and upper cutoff frequencies.
Useful Commands
FREQZ - Plots the magnitude and phase response of the system
IMPZ - Plots the impulse response of the system
ZPLANE - Plots the poles and zeros of the system
FIR1 - Generates a FIR filter
FFT - Computes the fast fourier transform of the signal
FILTER - Performs filtering on the signals
WAVRECORD - Record an audio sound
WAVPLAY - Play the audio sound
AUDIORECORDER - Audio recorder object.
RECORDBLOCKING - Record, and do not return control until recording completes.
PLAY - Play recorded audio. This method returns an audioplayer object.
GETAUDIODATA - Create an array that stores the recorded signal values.
GETPLAYER - Create an audioplayer object.
2|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Example:
Fs = 1000; % sample frequency
t= (1:300)/Fs; % number of sample elements
S1 = 2*sin(2*pi*80*t); % signal S1
figure; plot (S1); % plot of the signal
a2 = fft(S1,512); % discrete Fourier Transform of the signal S1
% is found by taking the 512-point fast Fourier Transform
w=(0:255)/256*(Fs/2); % frequency range
figure; plot(w,abs([a2(1:256)'])); % fft plot of the signal
3|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Exercises
For these exercises, use the command window to enter your code and save your answer to the
files under your account.
1.
a) Using your microphone record a 5-second audio saying “Digital Signal Processing” with
sampling frequency of 11025Hz. Note: Use your surname as a variable to record voice
signal.
Syntax: ____________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
4|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
2.
a) Create a low pass FIR filter with 6 th order filter, cutoff frequency of 1000Hz and sampling
frequency of 11025Hz. Determine the filter coefficients. Plot the poles and zeros of the
filter, its impulse response, and its freq response.
Syntax:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
B = _______________________________________________________________________
A = _______________________________________________________________________
Impulse Response
5|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Magnitude Response
b) Filter your original signal using low pass filter created earlier. Plot the frequency content of
filtered signal. Describe the waveform.
___________________________________________________________________________
___________________________________________________________________________
Syntax:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
6|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Frequency Response
3.
a) Generate a high pass 6th order FIR filter with a cutoff frequency of 2500Hz. Plot the poles
and zeros of the filter, its impulse response and magnitude response. Provide filter
coefficients.
Syntax:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
B = _______________________________________________________________________
A = _______________________________________________________________________
Impulse Response
7|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Magnitude Response
b) Filter your original signal using high pass filter created earlier. Plot the frequency content of
filtered signal. Describe the waveform.
Syntax:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
8|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Frequency Response
4.
a) Generate a band pass FIR filter with 15th order, cutoff frequencies of 2000Hz and 3000Hz.
Plot the poles and zeros of the filter and magnitude response.
Syntax:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
Impulse Response
9|Page EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Magnitude Response
b) Filter your original signal using band pass filter created earlier. Plot the frequency content of
filtered signal. Describe the waveform.
Syntax:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
10 | P a g e EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Frequency Response
5. Generate a stop band FIR filter with 20th order, cutoff frequencies of 800Hz and 2200Hz. Plot the
frequency contents of the signal and play it, plot the poles and zeros of the filter, its impulse
response and its frequency response.
Syntax:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
Impulse Response
11 | P a g e EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Magnitude Response
6. Filter your original signal using stop band filter created earlier. Plot the frequency content of
filtered signal. Describe the waveform.
Syntax:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
12 | P a g e EXERCISE 5
SY2021-2022 MAPUA UNIVERSITY
Frequency Response
13 | P a g e EXERCISE 5