TC-212 Digital Signal Processing
TC-212 Digital Signal Processing
LABORATORY WORKBOOK
For the Course
DIGITAL SIGNAL PROCESSING
(TC-212)
Instructor Name:
Student Name:
Semester: Year:
Department:
LABORATORY WORKBOOK
(TC-212)
Prepared By:
Ms. Tahniyat Aslam
Revised By:
Syed Muneeb Ahmed (Lecturer)
Reviewed By:
Dr. Hira Mariam (Assistant Professor)
Approved By:
The Board of Studies of Department of Telecommunications Engineering
CONTENTS
Lab Remarks/
Date Experiments CLO Page No.
No. Signature
To analyze the effect of Sampling and
1 3 1
Aliasing in discrete time sinusoid.
Objective:-
Equipment Required:-
Theory:-
Signals are physical quantities that carry information in their patterns of variation. Continuous-time
signals are continuous functions of time, while discrete-time signals are sequences of numbers. If the
values of a sequence are chosen from a finite set of numbers, the sequence is known as a digital signal.
Continuous-time, continuous-amplitude signals are also known as analog signals.
Signal processing is concerned with the acquisition, representation, manipulation, transformation, and
extraction of information from signals. In analog signal processing these operations are implemented
using analog electronic circuits. Digital signal processing involves the conversion of analog signals into
digital, processing the obtained sequence of finite precision numbers using a digital signal processor or
general purpose computer, and, if necessary, converting the resulting sequence back into analog form.
When stored in a digital computer, the numbers are held in memory locations, so they would be indexed
by memory address. In order to bridge the gap between analog and digital domain, we have to perform
two basic operations Sampling and Quantization.
Sampling Theorem: A continuous time signal x(t) can be reconstructed exactly from its samples
x(n)=x(nTs), if the samples are taken at a rate Fs=1/Ts that is greater than 2xFmax.
Aliasing: A common problem that arises when sampling a continuous signal is aliasing, where a sampled
signal has replications of its sinusoidal components which can interfere with other components. It is an
effect that causes two discrete time signals to become indistinct due to improper sampling (f d>1/2).
Aliasing also occurs on television whenever we see a car whose tires appear to be spinning in the wrong
direction. A television broadcast can be thought of as a series of images, sampled at a regular rate,
appearing on screen. If the wheels happen to rotate less than a full circle between frames (images), then
they appear to be turning slowly in the opposite direction.
Laboratory Task:-
1. Simulate and plot two continuous time (CT) sinusoids of 10 Hz and 110 Hz for 0 < t < 0.2 sec.
2. Sample both sinusoids at Fs = 100 samples/sec and plot them in discrete form.
3. Observe and note the aliasing effects.
4. Explore and learn.
Task-1:
Consider the following CT signal: x(t) = sin (2πFot). The sampled version will be:
x(n) =sin (2π F0/Fs n), where n is a set of integers and sampling interval Ts=1/Fs.
1
Plot the signal x(n) for n = 0 to 99 for Fs = 5 kHz and F1 = 0.5, 2, 3 and 4.5 kHz. Explain the similarities
and differences among various plots. Also mention that whether aliasing occurs or not.
Task-2:
Consider the given CT signal: x(t) = sin (2πFot). Suppose that F0 = 2 kHz and Fs = 50 kHz.
i) Plot the signal x(n). What will be the discrete frequency fd of the signal x(n)?
ii) Plot the signal y(n) created by taking the even numbered samples of x(n). Is this a sinusoidal signal?
Why? If so, what is the frequency?
Result:-
The code, results / output of all tasks must be attached with this lab.
2
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
3
LAB SESSION 02
Objective:-
Equipment Required:-
Theory:-
A discrete-time system is a computational process or algorithm that transforms or maps a sequence x(n),
called the input signal, into another sequence y(n), called the output signal. In practice, a discrete-time
system is a numerical algorithm that processes an input sequence x(n), to produce an output sequence
y(n).
A system is called causal if the present value of the output does not depend on future values of the input,
that is, y(n0) is determined by the values of x(n) for n ≤ n0, only. If the output of a system depends on
future values of its input, the system is noncausal.
Causality implies that if x(n) = 0 for n < n0, then y(n) = 0 for n < n0; that is, a causal system cannot
produce an output before the input is applied. Clearly, this problem does not exist if the entire input
sequence is already stored in memory. Although causality is necessary for the real-time implementation
of discrete-time systems, it is not really a problem in off-line applications where the input signal has been
already recorded.
The main premise of this lab is that the response of a linear time-invariant (LTI) system to any input can
be determined from its response h(n) to the unit sample sequence δ(n), using a formula known as
convolution summation. The sequence h(n), which is known as impulse response, can also be used to
infer all properties of a linear time-invariant system.
If we know the impulse response of an LTI system, we can compute its response to any input without
using the actual system y n x n * h n . Furthermore, if we have no access to the internal
implementation of the system (that is, we treat the system as a black box), we can try to “reverse-
engineer” the system from its impulse response. Convolution describes how a linear time-invariant
system modifies the input sequence to produce its output.
Convolving two waveforms in time domain is equivalent to multiply their spectra (frequency content) in
frequency domain.
Laboratory Task:-
4
Task 1:
What will happen if we provide input x(n) = {0,0,1,0,0} into the given system.
Task-2
a) Can you prove commutative property of the convolution?
b) Modify the code to prove Associative and Distributive properties of the convolution.
Task-3: What is Convolution reverb? Also explain how special effects can be created in sound using
convolution?
Result:-
The code, results / output of all tasks must be attached with this lab.
5
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
6
LAB SESSION 03
Objective:-
Equipment Required:-
Theory:-
The digitization of any real world signal usually involves two stages: sampling, i.e. the measurement at
discretely spaced time intervals, and quantization, i.e. the transformation of the measurements
(amplitudes) into finite-precision numbers (allowed discrete levels), such that they can be represented in
computer memory. Quantization leads to a loss in the signal quality, because it introduces a “quantization
error” or “quantization noise” or “distortion”. The number of bits used for each sample, called the bit
depth (bits/sample), determines the precision with which the sample amplitudes can be represented. Each
bit in a binary number holds either a 1 or a 0. The largest decimal number that can be represented with an
b-bit binary number is 2b - 1, and the number of different values that can be represented is 2b. For
example, the decimal values that can be represented with an 8-bit binary number range from 0 to 255, so
there are 256 different values. A bit depth of 8 allows 256 different discrete levels at which samples can
be approximated or recorded. A bit depth of 16 allows 216 = 65,536 discrete levels, which in turn provides
much higher precision than a bit depth of 8. With a bit depth of 3, 23 = 8 quantization levels ranging from
-4 to 3 are possible. By convention, half of the quantization levels are below the horizontal axis (that is
2b-1, of the quantization levels). One level is the horizontal axis itself (level 0), and 2 b-1 -1 levels are
above the horizontal axis. Quantization error represents the quality of quantization process but the total
error may also turn out to be zero, so another quality deciding parameter is used which is called signal-to-
quantization-noise-ratio (SQNR) and it can be defined as SQNR = 10 log10 (Px/Pe) where Px and Pe are
average powers of the DTCV and quantization error signal.
1 N 1 1 N 1
2
Px xq (n) x(n)
2
x ( n ) P
and e
N n 0 N n 0
Laboratory Task:-
1. Simulate a DTCV sinusoid of 1/50 cycles/sample with length of the signal be 500 samples.
2. Choose the method of Quantization (round-off, floor & ceil) and apply to the signal generated above.
3. Compute the error signals and SQNR.
4. Explore and observe.
7
c) Comment on the results obtained in steps (a) and (b).
d) Compare the experimentally measured SQNR with the theoretical SQNR predicted by the following
formula and comment on the differences and similarities.
SQNR 1.76 6.02 b [Note: b = No. of bits of Quantizer or bit depth]
Task-3:
a) Develop a MATLAB code to quantize both speech and audio signals (other than speech) to the desired
number of levels.
b) Play both the original and the quantized sounds in each case when rounding and floor are used. Which
quantization method leads to the best quality sound after quantization?
c) For both recorded speech signal and any ringtone, is there a point at which the signal quality
deteriorates drastically? At what point (if any) does it become incomprehensible?
d) Which signal‟s quality deteriorate faster as the number of levels decreases?
e) What improvement in terms of SQNR can we expect from adding one bit in the quantizer?
f) Do you think 4 bits/sample is acceptable for telephone systems? What about 2 bits/sample?
Task-4:
Develop a MATLAB code to import any image file and quantize it to the fewer bits/pixel than original
and observe the images. For example an 8-bit image can be quantized to 7, 6, 5, 4 bits/pixel. Print hard
copies of the 7, 6, 5, and 4 bits/pixel images, as well as the original. Describe the artefact (errors) that
appear in the image as the number of bits is lowered? Also note the number of bits/pixel at which the
image quality noticeably deteriorates.
Result:-
The code, results / output of all tasks must be attached with this lab.
8
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
9
LAB SESSION 4
Objective:-
Equipment Required:-
Theory:-
Mathematically, rxy n x n * y n .
Laboratory Task:-
Task 1:
Detection of periodic signal buried in noise. Given a sine wave signal (amplitude and frequency of your
choice and 100 samples on x-axis).
a) Apply auto-correlation of the sine wave signal and plot the output
b) Generate AWGN signal of equal number of samples (100)
c) Plot the noise signal
d) Add the sine wave signal (generated previously) to the noisy signal and plot the graph showing
the corrupt signal
e) Now, apply auto-correlation of the sine + noise signal and plot the output. What do you observe?
Write your conclusion.
Result:-
The code, results / output of all tasks must be attached with this lab.
10
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
Equipment Required:-
Theory:-
With the increased use of digital computers and specialized hardware in digital signal processing (DSP),
we are normally interested in those transforms that are suitable for digital computations. Because of the
continuous nature of spectrum provided by DTFT, direct implementation of the DTFT is not suitable on
such digital devices. In this lab we apply the Discrete Fourier Transform (DFT), which can be computed
efficiently on digital computers and other DSP boards. The most distinguishing feature of DFT is that it
can be applied to any type of signal whether periodic or non-periodic. It simply treats all signals as the
time limited or finite length sequence which corresponds to signal of interest/region of interest/sample
interval denoted by N.
The DFT is an extension of the DTFT for time-limited sequences with an additional restriction that the
spectrum is discretized to a finite set of values. The number of the frequency samples can have any value,
but is typically set equal to the length of the time-limited sequence x(n).
DFT plays a central role in spectral analysis, the implementation of digital filters, and a variety of other
signal processing applications. DFT is a powerful reversible operation for finite segments of discrete time
sequences. Many “fast” algorithms have been developed for computing the DFT, and collectively these
are known as Fast Fourier Transform (FFT) algorithms. The discovery of FFT algorithms established the
DFT as one of the fundamental tools in digital signal processing.
N 1 j 2 kn N 1
DFT analysis equation: X(k ) x(n)e N
x(n)WNnk ; k = 0, 1, 2, ,N-1
n 0 n 0
N 1 j 2 kn N 1
1
DFT synthesis equation: x(n)
N
X(k )e
k 0
N
X( K )WN nk ; n = 0, 1, 2, ,N-1
n 0
Fs
Frequency resolution is given by F (Hz)
N
Analysis frequencies or bin frequencies are given by Fk k F ; k = 0, 1, 2, ,N-1
Note: Always keep in mind that an FFT algorithm is not a different mathematical transform: it is simply
an efficient means to compute the DFT.
12
Laboratory Task:-
Task 1:
1. Load an audio file „noisy.wav‟ into MATLAB.
2. There is a tone added to the speech in this file. The objective is to find the frequency of this tone.
3. Computing the DFT of this signal
4. Generating frequency vector in Hz.
5. Displaying the spectrum (DFT) of audio file and observing the frequency of the added tone.
Task 2:
1. Try to remove the tone spikes by observing the spectra of the noisy signal.
2. Take Inverse DFT (ifft) of the modified spectra.
3. Listen to this new time-domain signal and see if the tone noise is removed.
Result:-
The code, results / output of all tasks must be attached with this lab.
13
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
14
LAB SESSION 06
Objective:-
Equipment Required:-
Theory:-
Circular convolution is another way of finding the convolution sum of two input signals. It resembles the
linear convolution, except that the sample values of one of the input signals is folded and right shifted
before the convolution sum is found.
Also note that circular convolution could also be found by taking DFT of the two input signals and
finding the product of two frequency domain signals. The inverse DFT of the product would give the
output of the signal in the time domain which is the circular convolution output.
Laboratory Task:-
Task 1:
Consider the following given sequences, x1 (n)= 1, 2,1, 2 and x2 (n)= 1, 2,3, 4 and apply circular
convolution. Include relevant figures/plots in your results.
Task 2:
Verify the result using DFT method. Include relevant figures/plots in your results.
Result:-
The code, results / output of all tasks must be attached with this lab.
15
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
16
LAB SESSION 07
Objective:-
Equipment Required:-
Theory:-
Zero Padding:
Zero padding is a simple concept; it simply refers to adding zeros to end of a time- domain signal to
increase its length.
MATLAB CODE
w = blackman(M) returns the M-point Blackman window function in array w.
Laboratory Task:-
Task 1:
Assume M = 64, Zero padding factor = 8. Plot the spectrum (normalized frequency) using Blackman
Window.
Result:-
The code, results / output of all tasks must be attached with this lab.
17
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
18
LAB SESSION 8(a)
Objective:-
Equipment Required:-
Theory:-
The Laplace Transform of a general continuous time signal x (t) is defined as;
x(t )e
st
X (s) dt
Where the complex variable s=δ + j w, with δ and w the real and imaginary parts. CTFT is a subset of
Laplace when δ =0. Since „δ‟ information is not present in CTFT, therefore information about stability
can only be obtained from Laplace. If pole lies on L.H.S of s-plane, system is stable. If pole lies on R.H.S
of s-plane, system is unstable. If pole lies on y(jw)-axis, system is marginally stable or oscillatory. If
system has FIR, it is stable. If system is IIR, it can be stable or unstable.
Laboratory Task:-
Make a folder at desktop and name it as your current directory within MATLAB.
Task 1:
Generate pole zero constellation in s-plane.
Plot corresponding Frequency (Bode magnitude) response.
Plot impulse response and determine that the system is FIR or IIR.
Task 2:
Modify location of poles in s-plane to observe the corresponding change in frequency and impulse
response.
Result:-
The code, results / output of all tasks must be attached with this lab.
19
LAB SESSION 8(b)
Objective:-
Equipment Required:-
Theory:-
Where the complex variable z r , with r the radius and w the angle. DTFT is a subset of z-
transform when r =1. Since „r‟ information is not present in DTFT, therefore information about stability
in discrete time can only be obtained from z-transform. If pole lies inside the unit circle, system is stable.
If pole lies outside the unit circle, system is unstable. If pole lies at the unit circle, system is marginally
stable or oscillatory. If system has FIR, it is stable. If system is IIR, it can be stable or unstable.
Laboratory Task:-
Make a folder at desktop and name it as your current directory within MATLAB.
Task 1:
Generate pole zero constellation in z-plane.
Plot corresponding Frequency (Bode magnitude) response.
Plot impulse response and determine that the system is FIR or IIR.
Task 2:
Modify location of poles in z-plane to observe the corresponding change in frequency and impulse
response. Change the location of poles from inside the unit circle to outside and at the unit circle and
observe the effects.
Result:-
The code, results / output of all tasks must be attached with this lab.
20
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
21
LAB SESSION 09
Objective:-
Equipment Required:-
Theory:-
Digital filters refers to the hard ware and software implementation of the mathematical algorithm which
accepts a digital signal as input and produces another digital signal as output whose wave shape,
amplitude and phase response has been modified in a specified manner.
Digital filter play very important role in DSP. Compare with analog filters they are preferred in number of
application due to following advantages.
Truly linear phase response
Better frequency response
Filtered and unfiltered data remains saved for further use.
1. FIR filters are Finite Impulse Response filters with no feedback, whereas IIR contains feedback.
2. Transfer function of FIR filter does not contain any non-trivial poles. Their frequency response is
solely dependent on zero locations. IIR filters contain poles as well as zeros.
3. As there are no poles, FIR filters cannot become unstable; however, IIR filters can become
unstable if any pole lies outside the unit circle in z-plane.
4. More number of coefficients is needed to design the desired filter in FIR than IIR.
FIR1 designs FIR filter using the window method. B = FIR1(N,Wn) designs an Nth order low pass FIR
digital filter and returns the filter coefficients in length N+1 vector B. The cutoff frequency Wn must be
between 0 < Wn < 1.0, with 1.0 corresponding to half the sample rate. The filter B is real and has
linear phase. The normalized gain of the filter at Wn is -6 dB.
B = FIR1(N,Wn,'stop') is a bandstop filter if Wn = [W1 W2]. You can also specify If Wn is a multi-
element vector, Wn = [W1 W2 W3 W4 W5 ... WN], FIR1 returns an order N multiband filter with bands 0 <
W < W1, W1 < W,< W2, ..., WN < W < 1.
22
B = FIR1(N,Wn,'DC-1') makes the first band a passband.
B = FIR1(N,Wn,'DC-0') makes the first band a stopband.
By default FIR1 uses a Hamming window. Other available windows, including Boxcar, Hann, Bartlett,
Blackman, Kaiser and Chebwin can be specified with an optional trailing argument. For example, B =
FIR1(N,Wn,kaiser(N+1,4)) uses a Kaiser window with beta=4.
B = FIR1(N,Wn,'high',chebwin(N+1,R)) uses a Chebyshev window.
freqz returns the frequency response based on the current filter coefficients.
Laboratory Task:-
Task 1:
Designing a Low Pass Filter that passes all frequencies below 1200 Hz. Take Fs = 8000 Hz,
F = 1200 Hz and N = 64. Take time vector as [0 : 1/Fs : 1].
Display the Magnitude Plot of the filter.
Display the pole-zero constellation.
Task 2:
Repeat similar procedure to implement:
High Pass Filter that pass all frequencies above 1200 Hz.
Band Pass Filter that passes frequencies between 1200 and 1800 Hz.
Band stop Filter that rejects frequencies between 1200 and 1800 Hz.
Notch filter that reject frequency between 1500 and 1550 Hz.
Task 3:
1. Create a signal vector containing two frequencies as: i) 100 Hz. and ii) 150 Hz, with Fs = 1000 Hz.
2. Design two band pass FIR filters with 64 coefficients and with pass bands as:
i) 75 to 125 Hz. and ii) 125 to 175 Hz.
3. Use both filters on the created signal and observe their outputs.
4. Plot frequency responses and pole-zero constellations of both filters and note observations.
Result:-
The code, results / output of all tasks must be attached with this lab.
23
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
24
LAB SESSION 10
Objective:-
Equipment Required:
Theory:-
Matlab contains various routines for design and analyzing digital filter IIR. Most of these are part of the
signal processing tool box. A selection of these filters is listed below.
Buttord- Butterworth filter order selection [N, Wn] = BUTTORD(Wp, Ws, Rp, Rs)
Ellipord- Elliptic filter order selection [N, Wn] = ELLIPORD(Wp, Ws, Rp, Rs)
Cheb1ord- Chebyshev Type I filter order selection [N, Wn] = CHEB1ORD(Wp, Ws, Rp, Rs)
returns the order N of the lowest order digital Butterworth, elliptic and Chebyshev Type I filter
respectively that loses no more than Rp dB in the pass band and has at least Rs dB of attenuation in the
stop band. Wp and Ws are the pass band and stop band edge frequencies, normalized from 0 to 1 (where 1
corresponds to π radians/sample).
BUTTORD also returns Wn, the Butterworth natural frequency (or, the "3 dB frequency") to use with
BUTTER to achieve the specifications.
ELLIPORD also returns Wn, the elliptic natural frequency to use with ELLIP to achieve the
specifications.
CHEB1ORD also returns Wn, the Chebyshev natural frequency to use with CHEBY1 to achieve the
specifications.
[B,A] = BUTTER(N,Wn) designs an Nth order lowpass digital Butterworth filter and returns the filter
coefficients in length N+1 vectors B (numerator) and A (denominator). The coefficients are listed in
descending powers of z. The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half
the sample rate.
25
If Wn is a two-element vector, Wn = [W1 W2], BUTTER returns an order 2N bandpass filter with
passband W1 < W < W2. [B,A] = BUTTER(N,Wn,'stop') is a bandstop filter.
When used with three left-hand arguments, as in [Z,P,K] = BUTTER(...), the zeros and poles are returned
in length N column vectors Z and P, and the gain in scalar K.
[B,A] = ELLIP(N,Rp,Rs,Wn) designs an Nth order low pass digital elliptic filter with Rp decibels of peak-
to-peak ripple and a minimum stop band attenuation of Rs decibels. ELLIP returns the filter coefficients in
length N+1 vectors B (numerator) and A (denominator).The cutoff frequency Wn must be 0.0 < Wn < 1.0,
with 1.0 corresponding to half the sample rate. Use Rp = 0.5 and Rs = 20 as starting points, if you are
unsure about choosing them.
If Wn is a two-element vector, Wn = [W1 W2], ELLIP returns an order 2N band pass filter with pass band
W1 < W < W2. [B,A] = ELLIP(N, Rp,Rs,Wn,'stop') is a band stop filter if Wn = [W1 W2]
When used with three left-hand arguments, as in [Z,P,K] = ELLIP(...), the zeros and poles are returned in
length N column vectors Z and P, and the gain in scalar K.
[B,A] = CHEBY1(N,R,Wn) designs an Nth order lowpass digital Chebyshev filter with R decibels of
peak-to-peak ripple in the passband. CHEBY1 returns the filter coefficients in length N+1 vectors B
(numerator) and A (denominator). The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0
corresponding to half the sample rate. Use R=0.5 as a starting point, if you are unsure about choosing R.
When used with three left-hand arguments, as in [Z,P,K] = CHEBY1(...), the zeros and poles are returned
in length N column vectors Z and P, and the gain in scalar K.
Laboratory Task:-
Task 1:
Buttord and Butter Filter,
Design IIR Low Pass Filter: Suppose our target is to design a filter to pass all frequencies below 1200 Hz
with pass band ripples = 1 dB and minimum stop band attenuation of 50 dB at 1500 Hz. The sampling
frequency for the filter is 8000 Hz;
26
Task 2:
Design IIR High Pass Filter: We will consider same filter but our target now is to pass all frequencies
above 1200 Hz. The sampling frequency for the filter is 8000 Hz.
Task 3:
Designing IIR Band Pass Filter: Now we wish to design a filter to pass all frequencies between 1200 Hz
and 2800 Hz with pass band ripples = 1 dB and minimum stop band attenuation of 50 dB. The sampling
frequency for the filter is 8000 Hz.
Task 4:
Design IIR Band Stop Filter: Now we wish to design a filter to stop all frequencies between 1200 Hz and
2800 Hz. The sampling frequency for the filter is 8000 Hz.
Result:-
The code, results / output of all tasks must be attached with this lab.
27
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
28
LAB SESSION 11
Objective:-
Equipment Required:-
Theory:-
Multirate simply means "multiple sampling rates". A multirate DSP system uses multiple sampling rates
within the system. Whenever a signal at one rate has to be used by a system that expects a different rate,
the rate has to be increased or decreased, and some processing is required to do so. Therefore "Multirate
DSP" really refers to the art or science of changing sampling rates.
Laboratory Task:-
Task 1:
Generate a time domain signal and its spectrum.
Task 2:
Down sample the generated signal by a factor and plot its spectrum. Pass signal by low pass filter and
observe its spectrum by down sampling it.
Task 3:
Up sample the generated signal by a factor and repeat task 2 for it.
Result:-
The code, results / output of all tasks must be attached with this lab.
29
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
30
LAB SESSION 12
Objective:-
Equipment Required:-
Theory:-
Filter Configurations:
All the filter design functions in the Signal Processing Toolbox operate with normalized frequencies, so
that they do not require the system sampling rate as an extra input argument. The normalized frequency is
always in the interval 0≤f≤1. For example, with a 1000 Hz sampling frequency, 300 Hz is 300=500 = 0.6.
To convert normalized frequency to angular frequency around the unit circle, multiply by π. To convert
normalized frequency back to Hertz, multiply by half the sample frequency.
Digital filter specifications are often given is terms of the loss function (in dB),
A( ) 20log10 G(e j )
Filter Design with SPTool:
The Filter Designer in the SPTool allows you to design and edit IIR and FIR filters of various lengths and
types, with lowpass, highpass, bandpass, and bandstop, and multiband configurations. To activate the
Filter Designer, click either the New button or the Edit button under the Filters list box in SPTool.
Try: sptool
Laboratory Task:-
Task 1:
Design a Lowpass, FIR Eqiripple filter, Minimum order, Fs=1000 Hz, Fpass=60 Hz, Fstop=200 Hz , Apass
=1dB, Astop =8dB. Note the following observations:
Magnitude and phase response
Phase and group delay
Filter impulse response
Filter information, filter coefficient , filter parameters
Pole-zero plot
31
Export the filter parameters (Num) to your workspace. Do size (Num) to obtain the size of your FIR filter.
Do freqz(Num,1). In the command window, do sptool. In sptool, Import Num to sptool. Change sampling
frequency from the default 1 to 1000. Now under SPTool: startup.spt, view the signal (Recall that Num is
just the values of the 18 point FIR filter; i.e. the FIR impuls response). Under Spectra, use\ create and do a
1024 point fft. Under options > Magnitude > Linear. Observe the difference between observing on a
linear and log scales. Do you see the equiripples in the stopband.
Task 2:
Now in fdatool, for the same specs as the FIR filter, design an IIR Butterworth filter. (Match exactly the
passband and stopbands). Look at the magnitude response. Linear phase? Look at the impulse response.
(Note that it is NOT symmetric). Look at the filter information. Did it meet specs? How many poles and
zeros? Does it have any properties dissimilar to that of FIR filter ? Explain.
Result:-
The results / output of all tasks must be attached with this lab.
32
NED University of Engineering & Technology
Department of Telecommunications Engineering
Remarks
33
LAB SESSION 13
(Open Ended Lab)
Objective:
To explore, analyse and develop experience in designing a digital system using the software platform of
MATLAB.
Problem Statement:
Design of digital filter and its application to remove noise from a real-world signal.
Background/Pre-Requisite:
To perform this activity student must have the knowledge and understanding of
Signal processing and digital filters.
MATLAB
Outcome:
This activity is mapped to CLO 3 of the course and results in the attainment of PLO 5 (Modern Tool
Usage)
Deliverables:
Write a detailed report on the design of your digital filter. The report should be in the standard format
including abstract, objectives, background, system working/description, results/code/discussions and
conclusions.
34
F/OBEM 01/18/00
Level of Attainment
Criterion Below Average Average Good Very Good Excellent
(1) (2) (3) (4) (5)
Completely
Completely
understood the
Did not try to Tried to Partially understood the
Problem problem but
understand the understand the understood the problem and was
Understanding could not
Problem problem problem able to explain it
explain it
properly
properly
Viability
Viability Viability
No viability Viability approach was
approach was approach was
Solution Viability approach was approach was appropriate,
appropriate but appropriate and
adopted inappropriate convincing and
not convincing convincing
appreciable
Major results One or more Key results are
Misses several
are notincluded. key results are presented in an
key results.
Plots and missing. orderly and
Data Analysis & Plots/Figures lack
No submission/No figures are Figures and logical sequence
Discussion proper
effort exhibited. poorly tables are using both text
identification in
constructed or present but and illustrative
the X and Y axis.
not present. contain minor materials (Plots
errors. and Figures).
Seemed to Clearly
Understood
Neither Adequate understand understood the
the question
Response to understands the understanding the main points question and
in-depth and
Questions question, nor could of the question of the question replied with
replied
reply. and reply. and replied to ease.
confidently.
those with ease.
Report Writing No submission/No Directions were Directions were Minor errors in Directions were
effort exhibited not followed. not explicitly format or followed and
followed. procedures were questions were
encountered answered
correctly
35