Lab 5
Lab 5
Lab 5
TITLE :
MATLAB and Simulink
DATE OF
: Fall 2023
EXPERIMENT
LAB NUMBER : 5
NAME :
ROLL NO :
COMMUNICATION SYSTEMS LAB (308202)
Instructions:
1. You are required to complete and submit ALL the tasks given at the end of each tutorial during
your lab timings strictly.
2. At the end of the lab manual, you will find some experiments which are required to be done as
home assignment and submitted before the next lab.
3. Please show your complete work, through Simulink models and results for both lab performance
(during lab timings) and lab report (report submitted as home assignment).
4. Save your models after performing each step to avoid loss of your work due to any reason.
Objective:
In this lab, you will learn to conduct simulation in Simulink/MATLAB to explore the concepts of:
a. Commonly used filters in communication systems.
b. Designing digital filters through various methods.
5.1 Filters in Communication Systems:
The most common processing of a signal in a communication system consists of passing the signal through
a linear time-invariant system, often referred to as ‘filters’. These systems are usually applied to reduce or
eliminate some undesirable frequency components in the signal, to compensate for some undesirable
distortion of the signal, or to accentuate some characteristic of a signal.
5.1.1 Types of filters based on their magnitude responses:
Brief description of most commonly used ideal frequency selective filters (selecting specific frequency
range of the input signals) is given below.
Low-pass filter:
An ideal low-pass filter with cutoff frequency 𝑓𝑐 passes all the frequency components of a signal below 𝑓𝑐
without distortion and stops all components with frequencies above 𝑓𝑐.
High-pass filter:
An ideal high-pass filter with cutoff frequency 𝑓𝑐 stops all the frequency components of the signal below
𝑓𝑐 and passes all the components with frequencies above 𝑓𝑐 without any distortion.
Band-pass filter:
An ideal band-pass filter with cutoff frequencies 𝑓1 and 𝑓2 passes all the frequency components of a signal
between 𝑓1 and 𝑓2 without distortion and stops all the other frequency components.
Band-stop filter:
An ideal band-stop filter with cutoff frequencies 𝑓1 and 𝑓2 stops all the frequency components of a signal
between 𝑓1 and 𝑓2 and passes all the other frequency components without any distortion.
𝑀−1
𝑀−1
Similarly, equation set (5.2) is for a generic infinite impulse response (IIR) system:
𝑁−1 𝑀−1
Comparing the two impulse responses, Equation (5.1b) shows a finite duration impulse response while
Equation (5.2b) shows an impulse response with infinite number of samples.
All the four types of filters discussed in Section 5.1.1 can be developed with either FIR and IIR systems.
Note: You have worked on analog/IIR filters (such as Chebyshev, Butterworth, Bessel etc.) in your
previous courses, however you will study the details of digital/FIR filters in Digital Signal Processing
course and in this lab we will focus on the basics of the filter design.
5.2 Tutorial #1: Filter designing (IIR) using “Filter Design & Analysis Tool (fdatool)”:
In this section, you will learn to design IIR filters using Filter Design & Analysis Tool in MATLAB.
i. Open MATLAB and type ‘fdatool’ on the command line. You should be able to see a GUI as
given in Figure 5.3.
ii. Set various parameters of the open Filter Design as follows:
iii. Click on Design Filter after setting the parameters and observe the magnitude response of the
filter. Under the Current Filter Information, you will be able to see the specifications of the
designed filter.
iv. Change the frequency specifications as follows: Fs: 40e3, Fpass: 10e3, and Fstop: 15e3.
v. Now, change the Filter Order: Specify Order and enter different orders such as 50, 100, and 500
and click on the Design Filter tab to see the magnitude response of the designed filter. You can
notice the “sharpness” in the transition band with increase in the filter order.
vi. Keeping the frequency specifications as set in Step (iv) change the parameter Astop (in Magnitude
Specifications) to 100, 200 and 500, and note the difference in the magnitude response and order
of the designed filters, obtained after Design Filter tab is clicked.
vii. Lastly, keeping the Astop: 80, change the parameter Fstop (in Frequency specifications) to 12e3,
11e3 and 10.1e3. Note the difference in the resultant magnitude responses and order of the
designed filters, obtained after clicking Design Filter tab.
Task #1:
Design a high-pass Elliptic filter with minimum order. Assume the sampling frequency to be 50 kHz and
Fpass to 20 kHz. Set Fstop to be in kHz with the numerical value equivalent to the sum of last two digits
of your registration number.
5.3 Tutorial #2: Filter designing (FIR) using “Filter Design & Analysis Tool (fdatool)”:
In this section, you will learn to design FIR filters using Filter Design & Analysis Tool in MATLAB.
ii. Set wc: 0.2 and click on the Design Filter tab to view the magnitude response of the designed
filter.
iii. Keeping the same cut-off frequency as set in Step (ii), change window types to Blackman,
Hamming, and Rectangular and view the resultant magnitude responses. These window names
refer to different mathematical formulae that are used to design a filter.
iv. You can change the cut-off frequency values to see the effect on magnitude response.
Task #2:
𝑋𝑋
Design a bandpass filter with Kaiser window and an order equal to 50, and wc1 = 0.1 + and wc2 =
100
𝑋𝑋
0.2 + , where 𝑋𝑋 = last two digits of your registration number.
100
iii. In the main model window, drag the other components to complete the model as appearing in
Figure 5.4. Run your simulation for 0.02 seconds.
iv. Now, change the Minimum stopband attenuation (dB): 150 in the parameters of Lowpass filter
block, and after clicking on Apply, run the simulation and compare the results with the ones
obtained in Step (iii). Different parameters of designed filter can be viewed/analyzed in the “Filter
visualization Tool” (obtained after clicking View Filter Response).
v. From the same library, as mentioned in Step (ii), use a Bandpass filter now and set following
parameters:
a. Impulse response: FIR,
b. Frequency units: Hz,
c. Input sample rate: 1/(1e-5),
d. Stopband frequency 1: 8e3,
e. Passband frequency 1: 9e3,
f. Passband frequency 2: 11e3,
g. Stopband frequency 2: 12 e3,
Click Apply and view the designed filter’s response.
vi. Run your simulation for 0.02 seconds and view the output, both on scope as well as on spectrum
analyzer.
vii. Change the Stopband attenuation 1 & 2 to 100 each in Bandpass filter’s block parameters and re-
run your simulation to compare the results.
viii. Change the Impulse response to IIR now. Note the difference in the designed filter (and the output
response on spectrum analyzer).
Task #3:
𝑋𝑋−1
Generate an input signal as a sum of two sine wave signals with frequencies: 𝑓1 = (5 + 5 ) kHz, and
90
𝑋𝑋−1
𝑓2 = (5 90+ 10 ) kHz. Set an appropriate sampling time and simulation-run-time. Filter out the low-
frequency component in your generated signal.
5.5 Experiments:
i. Reproduce the Simulink model, as developed in Figure 5.4, with Analog Filter Design now.
𝑋𝑋−1
Develop the input signal as sum of three sine wave signals with frequencies: 𝑓1 = (6 +6)
𝑋𝑋−1 𝑋𝑋−1 90
kHz, 𝑓 = (6 + 12 ) kHz and 𝑓 = (6 + 18 ) kHz. Filter out the frequency 𝑓 with
2 90 3 90 2
any chosen Design method of your choice. Submit your results for different Filter orders. Since
the output from the filter is apparently a continuous-time signal therefore this signal cannot be
directly displayed on a Spectrum Analyzer. For this purpose, you need to connect a Zero-Order
Hold block between the filter’s output and the Spectrum Analyzer’s input.
ii. Repeat the above problem with Digital Filter Design block instead. Keeping the same settings,
produce the results. You will not however need the Zero-Order Hold block now.