0% found this document useful (0 votes)
405 views6 pages

Lab 14 (DSP Open Ended)

1. This lab explores decimation and interpolation of sampled signals by analyzing the effect of changing the decimation/interpolation factor and incorporating filters. 2. MATLAB commands like decimate, interp and filters are used to decimate and reconstruct signals, and the effects are observed in the time domain using audioplayer and in the frequency domain using FFT plots. 3. Simulink is also used to model the decimation and interpolation system with sources, sinks and filters to further analyze the effects in more detail. A notch filter is designed using fdatool to remove aliasing.

Uploaded by

amna zia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
405 views6 pages

Lab 14 (DSP Open Ended)

1. This lab explores decimation and interpolation of sampled signals by analyzing the effect of changing the decimation/interpolation factor and incorporating filters. 2. MATLAB commands like decimate, interp and filters are used to decimate and reconstruct signals, and the effects are observed in the time domain using audioplayer and in the frequency domain using FFT plots. 3. Simulink is also used to model the decimation and interpolation system with sources, sinks and filters to further analyze the effects in more detail. A notch filter is designed using fdatool to remove aliasing.

Uploaded by

amna zia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Electrical Engineering Department Instructor: Engr.

Sharoze Sohail

Lab 14: (Open Ended Lab)


Decimation & Interpolation
Objective:
In today’s Lab we will take results from previous lab i.e. the sampled signal achieved at the end of Lab 2
and convert it back to continuous time signal. In this lab the effect of reconstruction time period on
continuous time signal will also be analyzed.
Commands to be used:
• plot • play • fftshift
• interp • audioread • linspace
• decimate • fft • hold on/off
Help on these commands is available in MATLAB help directory.

Procedure:
1. Open M-file or M-Book
2. Save it by any useful name but remember not to start the name by any numeric digit, do not use
any special character other than under-the-score ( _ ) and also remember not to give any space
in the name.
Task I:
1. Read an audio signal from matlab toolbox using the command
[Y, FS]=audioread('audio48kHz.wav');
2. Now use factor as a variable for decimation & interpolation factor, assign it values as 4, 8, 16 ,
20. And using play command analyze the effect on sound quality as well as spectrum using the
following code.
factor = 8;
p = audioplayer(Y, FS);
play(p);
Yf=fftshift(fft(Y));
subplot(311),plot(linspace(-FS/2,FS/2,length(Yf))/1000,abs(Yf))
Y_dec=decimate(Y,factor);
p = audioplayer(Y_dec, FS);
play(p);
Yf=fftshift(fft(Y_dec));
subplot(312),plot(linspace(-FS/2,FS/2,length(Yf))/1000,abs(Yf))
Y_inter=interp(Y_dec,factor);
p = audioplayer(Y_inter, FS);
play(p);
Yf=fftshift(fft(Y_inter));
subplot(313),plot(linspace(-FS/2,FS/2,length(Yf))/1000,abs(Yf))

Task II:
1. For analyzing the Decimation and Interpolation system in a more detailed and preferable
manner Matlab Simulink will be used, for help certain step are described below.
a. Getting Started: Click the SIMULINK icon in toolbar as shown in figure beneath or type
SIMULINK in command window.
Electrical Engineering Department Instructor: Engr. Sharoze Sohail

b. The following window will open called SIMULINK library browser


New
Model Icon

c. Now open a SIMULINK *.slx file by clicking the New model icon as shown in figure above. The
model window is where your work by dragging the contents from SIMULINK library browser.
Electrical Engineering Department Instructor: Engr. Sharoze Sohail

.slx file

d. Now with the help of your teacher’s instructions design the following model (use sources & sinks
from DSP System Toolbox):

e. The above model is a designed for a 100 Hz signal with a sampling frequency of 1000 and 100
frames per second output, the results in the spectrum analyzer as in dBm Scale. Further details
will be given by the Lab instructor.
f. The output from the above spectrum analyzers will be as following:
Electrical Engineering Department Instructor: Engr. Sharoze Sohail

50

0
0

-50

-50

dBm
dBm

-100

-150 -100

-200 RBW: 488.28 mHz, NFFT: 1537


RBW: 976.56 mHz, NFFT: 1537 -150
Span: 1 kHz, CF: 0 Hz Span: 500 Hz, CF: 0 Hz
-500 0 500 -200 -100 0 100 200
Frequency (Hz) Frequency (Hz)

Original Signal Down Sampled


20

-20

-40
dBm

-60

-80

-100

-120
RBW: 1.46 Hz, NFFT: 1537
-140 Span: 1.5 kHz, CF: 0 Hz
-600 -400 -200 0 200 400 600
Frequency (Hz)

UpSampled

g. As we can see we have not used any kind of pre or post filters so the spectrums especially in
case of up-sampler can be observed as tripled. If the M & L factors are changed from 2 & 3,
respectively, further disturbances might be noted.
h. Note: with the up-sampler and the down-sampler the frequency axis alters accordingly.
i. Adding a filter after, between and before or placing up-sampler first following down-sampler
with a filter in between will add more information for your analysis.
Task III:
2. The next and final task is to design an appropriate filter for final analysis.
a. For filter designing we will use the “fdatool”, type it in matlab command window and the
following window will appear.
Electrical Engineering Department Instructor: Engr. Sharoze Sohail

b. As defined by its name it can be used for the following purposes:


 Design filters
 Analyze filters
 Modify existing filter designs
c. The GUI has three main regions:
● The Current Filter Information region
The upper half of the GUI displays information on filter specifications and responses for the
current filter. The Current Filter Information region, in the upper left, displays filter
properties, namely the filter structure, order, number of sections used and whether the
filter is stable or not. It also provides access to the Filter manager for working with multiple
filters.
● The Filter Display region
The Filter Display region, in the upper right, displays various filter responses, such as,
magnitude response, group delay and filter coefficients
● The Design panel
The lower half of the GUI is the interactive portion of FDATool. The Design Panel, in the
lower half is where you define your filter specifications. It controls what is displayed in the
other two upper regions. Other panels can be displayed in the lower half by using the
sidebar buttons.
d. Now using this toolbox we will design a notch filter. Select IIR in Filter Design Method and
choose a Lowpass filter from the list.
e. For the Frequency Specifications, set Units to Hz and Fs, the full scale frequency, to 3000
(because after the up-sampler the samples are 3*1000/sec). The scaled axis will be from 0
to Fs/2 i.e. 1500.
f. Set the cutoff as Fs/(2*L) in our case L=3. So the cutoff frequency in Hz will be 500.
g. Leave the Magnitude Specification in dB (the default) and leave Apass as 1.
h. Click Design Filter.
i. FDATool computes the filter coefficients and plots the filter magnitude response in the
analysis area for you to review.
j. Now this designed filter can be used by the SIMULINK file as an anti-aliasing filter.
k. Now click on File tab and from there Import to Simulink, a button “Realize Model” will
appear, click it; and you will be able to import your designed filter to your Simulink file.
3. Your final module will look as below, now analyze your output.
Electrical Engineering Department Instructor: Engr. Sharoze Sohail

Questions:

1. In Task I, when changing the factor from 4 up till, what do you think happened? Explain the
theory behind this, listen to the audio file, did you notice any difference in the audio quality? If
so, what happened? What about the storage space it took? What happened to this signal in
frequency domain? What was expected to happen?
2. While using the Simulink model what do you think is the difference between the use of a down-
sample followed by up-sampler & up-sampler followed by a down-sampler?
3. What is the difference between use of pre, post & mid filter, for down-sample followed by up-
sampler?

You might also like