212 EEE312 LabSheet 05
212 EEE312 LabSheet 05
where . Note that the DFT is also an N-point sequence, that is, it is not
defined outside
1 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
IDFT: The inverse discrete Fourier transform (IDFT) of an N-point DFT is given
by (once again is not defined outside )
(3)
(4)
where and are a DFT matrix and its conjugate, respectively. The following
MATLAB functions implement the above equations.
Custom Functions
2 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Example 5.1:
Let x(n) be a 4-point sequence defined as, x = [1, 0.5, 0.2, 0.1] for 0 ≤n ≤ 3, zero
otherwise.
Output:
magX =
1.8000 0.8944 0.6000 0.8944
phaX =
0 -26.5651 -0.0000 26.5651
Figure:
3 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Output:
ans =
Output:
At Command window:
Figure:
4 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Can you see that DFT (magnitude) is symmetric about middle point (excluding first
point)?
You have noticed similarity in frequency response between original and zero padding
versions. Now try again with a new value of x=[ 1, 1, 1, 1] and see the difference again.
Example 5.4:
For the sequence , use the following MATLAB commands
to determine the 30-point DFT of .
Solution:
MATLAB Code:
Output:
Figure:
5 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Circular folding: If an N-point sequence is folded, the result x(-n) would not be an
N-point sequence, and it would not be possible to compute DFT. Therefore we use the
modulo-N operation on the argument (-n) and define folding by,
Example 5.5:
Let
Output:
6 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Solution:
(b) MATLAB Code:
Output:
7 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
What changes do you observe in frequency domain due to circular folding
operation?
8 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
The DFT introduced previously is the only tramsform that is discrete in both the time and
the frequency domains, and is defined for finite-duration sequences. Although it is a
computable transform, the straightforward implementation of it is very inefficient,
especially when the sequence length N is large. In 1965 Cooley and Tukey showed a
procedure to substantially reduce the amount of computations involved in the DFT. This
led to the explosion of application of the DFT, including in digital signal processing area.
Furthermore, is also led to the development of other efficient algorithms. All these
efficient algorithms are collectively known as Fast Fourier Transform (FFT) algorithms.
In an efficiently designed algorithm the number of computations should ne constant per
data sample, and therefore the total number of computations should be linear with respect
to N. The number of DFT computations for an N-point sequence depends quadratically on
N, which will be denoted by the notation
(1)
FFT algorithms can reduce the quadratic dependence on N of the DFT. Theoretically, the
number of computations used in the FFT algorithms could be as small as, depending on
the radix used in the alogorithm,
(2)
9 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Output:
10 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Original frequency of sinusoid can be found from FFT as follows:
Here, fo = fF * f /(N-1)
fo = original freq,
fF = (index of freq in FFT) – 1, (excluding 1st element, DC value)
f = sampling frequency;
N = number of samples (in time series or its FFT)
MATLAB Code:
Output:
Figure-1:
12 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Figure-2:
Figure-3:
13 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Comment on the above three figures.
Can you reconstruct the original signal from the noisy one by manipulating the fourier
transform?
Try yourself first, then consider the following code:
Home Task: Reconstruct the noise-free ECG signal from the noisy-ECG signal.
16 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
Output:
Comment: The main reason the amplitudes are not exactly at 0.7 and 1 is because of
the noise. Several executions of this code (including recomputation of y) will produce
different approximations to 0.7 and 1. The other reason is that you have a finite length
signal. Increasing L from 1000 to 10000 in the example above will produce much better
approximations on average.
Home Task: Reconstruct the noise-free signal from the noisy signal.
In Lab Evaluation:
ILE 5.1 A 12-point sequence x(n) is defined as
17 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU
ILE 5.2
Let
Home Work
HW5.1 Correlation is an effective method of detecting signals buried in noise. Noise are
essentially uncorrelated.This means that, if we correlate a noisy signal with itself, the
correlation will be only due to the signal only.This will exhibit a sharp peak at n=0.
Generate two noisy signals by adding noise to a 20Hz sinusoid sampled at Ts=0.01 sec for
1 seconds.
(a) Verify the presence of the signal by ploting correlation of the two noisy signals.
(b)Can you see the presence of periodicity in correlation plot? Where it coming from?
(c) Plot FFT spectrum of the correlation.
(d)Can you see the original sinusoid frequency in the FFT?
HW5.2 During transmission, a message signal gets contaminated by a low-frequency signal and
high-frequency noise. The message can be decoded only by displaying it in the time
domain. The contaminated signal x[n] is provided at server-7 as mystery1.mat.
Load this signal into Matlab (use the command load mystery1). In an effort to decode the
message,try the following procedure and determine what the decoded message says.
(a) Display the contaminated signal. Can you “read” the message?
(b)Display the DFT of the signal to identify the range of the message spectrum.
(c) First zero out the DFT component corresponding to the low-frequency
contamination and obtain its IDFT y[n].
(d)Next, zero out the DFT component corresponding to the high-frequency
contamination and obtain its IDFT y[n].
(e) Take the IDFT to obtain the filtered signal and display it to decode the message.
18 | Page
Prepared by BKM Mizanur Rahman, updated by MK Masukur Rahman, Dept of EEE, UIU