You are on page 1of 53

DSP-2 (DFS & DFT) 1 of 53 Dr.

Ravi Billa
Digital Signal Processing 2 December 26, 2009

II. Discrete Fourier series

2007 Syllabus: Properties of discrete Fourier series, DFS representation of periodic sequences,
Discrete Fourier transforms, Properties of DFT, Linear convolution of sequences using DFT,
Computation of DFT, Relation between z-transform and DFS.

Contents:
2.1 Fourier analysis Recapitulation
2.2 Discrete Fourier series
2.3 Properties of discrete Fourier series
2.4 The discrete Fourier transform (DFT)
2.5 Properties of DFT
2.6 Filtering through DFT/FFT
2.7 Picket-fence effect

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 2 of 53 Dr. Ravi Billa
2.1 Fourier analysis - Recapitulation

(1) The Fourier series (FS) of a continuous-time periodic signal, x(t), with fundamental period
T
0
, is given by the synthesis equation
x(t) =

= k
t F k j
k
e X
0
2t

The Fourier coefficients, X
k
, are given by the analysis equation
X
k
=
0
1
T
}

0
0
2
) (
T
t kF j
dt e t x
t

The fundamental frequency, F
0
(Hz), and the period, T
0
(seconds), are related by F
0
= 1/T
0
.

(2) The Fourier transform (FT) of a continuous-time aperiodic signal, x(t), is given by the
analysis equation
X(F) =
}

dt e t x
t F j t 2
) ( or X() =
}


O
dt e t x
t j
) (
Here and F are analog frequencies, with = 2F. The inverse Fourier transform is given by
the synthesis equation
x(t) =
}


dF e F X
t F j t 2
) ( or x(t) =
t 2
1
}


O
O O d e X
t j
) (

(3) The Fourier series (DTFS/DFS) for a discrete-time periodic signal (periodic sequence),
x(n), with fundamental period N is given by the synthesis equation
x(n) =

=
1
0
/ 2
N
k
N n k j
k
e X
t
, 0 s n s N1
The Fourier coefficient X
k
are given by the analysis equation
X
k
=
N
1

1
0
/ 2
) (
N
n
N n k j
e n x
t
, 0 s k s N1
This is called the discrete-time Fourier series (DTFS) or just discrete Fourier series (DFS) for
short. The sequence of coefficients, X
k
, also is periodic with period N.
These two equations are derived below.
(Note that if the factor (1/N) is associated with x(n) rather than with X
k
the two DFS
equations are identical to the two DFT equations which are derived below in their standard
form.)

(4) The Fourier transform (DTFT) of a finite energy discrete-time aperiodic signal
(aperiodic sequence), x(n), is given by the analysis equation (some write X(e
j
) instead of X())
X() =

n
n j
e n x
e
) (
Certain convergence conditions apply to this analysis equation concerning the type of signal x(n).
We shall call this the discrete-time Fourier transform (DTFT). Physically X() represents the
frequency content of the signal x(n). X() is periodic with period 2.
The inverse discrete-time Fourier transform is given by the synthesis equation
x(n) =
t 2
1
}
t
e
e e
2
) ( d e X
n j

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 3 of 53 Dr. Ravi Billa
The basic difference between the Fourier transform of a continuous-time signal and the
Fourier transform of a discrete-time signal is this: For continuous time signals the Fourier
transform, and hence the spectrum of the signal, have a frequency range (, ); in contrast, for
a discrete-time signal the frequency range of the DTFT is unique over the interval of (, ) or,
equivalently, (0, 2).
Since X() is a periodic function of the frequency variable , it has a Fourier series
expansion; in fact, the Fourier coefficients are the x(n) values.


2.2 Discrete Fourier series

Let x(n) be a real periodic discrete-time sequence of period N. If x(n) can be expressed as a
weighted sum of complex exponentials, the response of a linear system to x(n) is easily
determined by superposition. By analogy with the Fourier series representation of a periodic
continuous-time signal, we can expect that we can obtain a similar representation for the periodic
discrete-time sequence x(n). That is, we seek a representation for x(n) of the form
x(n) =

k
n k j
k
e X
0
e
for all n
Here X
k
are the Fourier coefficients and
0
= 2/N is the fundamental (digital) frequency (as
0

= 2/T
0
= 2F
0
is in the case of continuous-time Fourier series). With k
0
=
k
=
|
.
|

\
|
N
k
t 2
, the
above is also written
x(n) =

k
n j
k
k
e X
e
or

k
N n k j
k
e X
/ 2t

The function
N n k j
e
/ 2t
is periodic in k with a periodicity of N and there are only N distinct
functions in the set { }
N n k j
e
/ 2t
corresponding to k = 0, 1, 2, ..., N1. Thus the representation for
x(n) contains only N terms (as opposed to infinitely many terms in the continuous-time case)
x(n) =

> < = N k
N n k j
k
e X
/ 2t

The summation can be done over any N consecutive values of k, indicated by the summation
index k = <N>. For the most part, however, we shall consider the range 0 k N1, and the
representation for x(n) is then written as
x(n) =

=
1
0
/ 2
N
k
N n k j
k
e X
t
for all n
This equation is the discrete-time Fourier series (DTFS) or just discrete Fourier series (DFS)
of the periodic sequence x(n) with coefficients X
k
.
The coefficients X
k
or X(k) are given by (we skip the algebra S&S)
X
k
=
N
1

1
0
/ 2
) (
N
n
N n k j
e n x
t
, 0 s k s N1 (B)
Note that the sequence of Fourier coefficients {X
k
} is periodic with period = N. That is, X
k
=
X
k+N
. The coefficients can be interpreted to be a sequence of finite length, given by Eq. (B) for k
= 0, 1, 2, , N1 only and zero otherwise, or as a periodic sequence defined for all k by Eq. (B).
Clearly both of these interpretations are equivalent.
Because the Fourier series for discrete-time periodic signals is a finite sum defined
entirely by the values of the signal over one period, the series always converges. The Fourier
series provides an exact alternative representation of the time signal, and issues such as
convergence or the Gibbs phenomena do not arise.
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 4 of 53 Dr. Ravi Billa
The periodic sequence X(k) has a convenient interpretation as samples on the unit circle,
equally spaced in angle, of the z-transform of one period of x(n). Let x
1
(n) represent one period
of x(n). That is,

x
1
(n) = x(n), 0 s n s N1
0, otherwise

Then X
1
(z) =

n
n
z n x ) (
1
=

1
0
1
) (
N
n
n
z n x , and X(k) =
N k j
e z
z X
/ 2
) (
1
t
=
. This then corresponds to
sampling the z-transform X
1
(z) at N points equally spaced in angle around the unit circle, with the
first such sample occurring at z = 1. (Note that the periodic sequence x(n) cannot be represented
by its z-transform since there is no value of z for which the z-transform will converge. However,
x
1
(n) does have a z-transform.)


2.3 Properties of discrete Fourier series

Properties of discrete Fourier series (DFS) for periodic sequences The following notation is
used:
p = periodic; e = even; o = odd
W
N
=
N j
e
/ 2t

Re [.] = Real part of
Im [.] = Imaginary part of
|.| = Magnitude of
Arg (.) = Argument of

The following properties should be noted.

Sequence DFS Sequence DFS
1 x
p
(n+m)
m k
N
W

X
p
(k)
4 Re [x
p
(n)] X
pe
(k)
2
) (
*
n x
p
) (
*
k X
p

5 j Im [x
p
(n)] X
po
(k)
3
) (
*
n x
p
) (
*
k X
p



Example 2.3.1 Show that DFS {x
p
(n+m)} =
m k
N
W

X
p
(k).
Solution We have
DFS { x
p
(n+m)} =

=
+
1
0
) (
N
n
kn
N p
W m n x
Set n+m = so that n = m and the limits n = 0 to N1 become = m to N1+m. Then the RHS
becomes
=

+
=

m N
m
km
N
k
N p
W W x
1
) (


Since x
p
() is periodic with period N the summation can be done over any interval of length N.
Thus
DFS { x
p
(n+m)} =

1
0
) (
N
km
N
k
N p
W W x

=
m k
N
W

=
1
0
) (
N
k
N p
W x


=
m k
N
W

X
p
(k) QED
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 5 of 53 Dr. Ravi Billa

Example 2.3.2 Show that DFS { ) (
*
n x
p
} = ) (
*
k X
p
.
Solution We have
DFS { ) (
*
n x
p
} =

=
1
0
*
) (
N
n
n k
N p
W n x =
*
*
1
0
*
) (

|
|
.
|

\
|

=
N
n
n k
N p
W n x
=
*
1
0
) (
)
`

N
n
n k
N p
W n x = { }
*
) ( k X
p
= ) (
*
k X
p
QED
Based on the properties above we can show that for a real periodic sequence x
p
(n), the
following symmetry properties of the discrete Fourier series hold:

1. Re [X
p
(k)] = Re [X
p
(k)] 3. |X
p
(k)| = |X
p
(k)|
2. Im [X
p
(k)] = Im [X
p
(k)] 4. arg X
p
(k) = arg X
p
(k)


2.4 The discrete Fourier transform (DFT)

(Omit) The discrete Fourier transform (DFT) derived from the Fourier series The exponential
Fourier series of a continuous time periodic signal x(t) with fundamental period T
0
is given by
the synthesis equation
x(t) =

= k
t F k j
k
e X
0
2t
(1)
where the Fourier coefficients X
k
are given by the analysis equation
X
k =

}

0
0
2
0
) (
1
T
t kF j
dt e t x
T
t
(2)
with the fundamental frequency F
0
and the period T
0
related by F
0
(Hz) = 1/T
0
(sec).
To obtain finite-sum approximations for the above two equations, consider the analog
periodic signal x(t) shown in Figure and its sampled version x
s
(nT). Using x
s
(nT), we can
approximate the integral for X
k
by the sum
X
k
=
0
1
T

1
0
2
0
) (
N
n
nT F k j
s
T e nT x
t
, k = 0, 1, , N1
=
N
1

1
0
/ 2
) (
N
n
N n k j
e n x
t
, k = 0, 1, , N1
where we used the relation F
0
T = 1/N, and approximated dt (or At) by T, and have used the
shorthand notation x(n) = x
s
(nT). (This procedure is similar to that used in a typical introduction
to integral calculus).
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 6 of 53 Dr. Ravi Billa
A finite series approximation for x(t) is obtained by truncating the series for x(t) in
equation (1) to N terms and substituting t = nT and F
0
= 1/TN. This will necessarily give the
discrete sequence x(n) instead of the continuous function x(t):
x(n) or x
n
=

=
1
0
/ 2
N
k
N n k j
k
e X
t
, n = 0, 1, , N1
























The above two equations define the discrete Fourier transform (DFT) pair. A slight
adjustment of the (1/N) factor is needed so as to conform to standard usage. The adjustment
consists of moving the (1/N) factor from one equation to the other. Then the direct DFT of the
time series x
0
, x
1
, , x
N-1
is defined as
X
k
=

1
0
/ 2
N
n
N n k j
n
e x
t
, k = 0, 1, , N1 (3)
And the inverse DFT is defined as
x
n
=
N
1

=
1
0
/ 2
N
k
N n k j
k
e X
t
, n = 0, 1, , N1 (4)
It can be shown that substituting equation (3) into equation (4) produces an identity, so that the
two equations are indeed mutually inverse operations and therefore constitute a valid transform
pair.
(End of Omit)

The discrete Fourier transform as a discretized (sampled) version of the DTFT A finite-
duration sequence x(n) of length N (the length N may have been achieved by zero-padding a
sequence of shorter length) has a Fourier transform denoted X() or X(e
j
),
X() =

1
0
) (
N
n
n j
e n x
e
, 0 s < 2
T
0
0
x(t)
t
2T
0
T
0
= NT
(N1)T
x
s
(nT)
T 2T 0
x(t)
t
N samples at n = 0, 1, , N1
t or dt = T = T
0
/N
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 7 of 53 Dr. Ravi Billa
X() is a continuous function of and has a period of 2. If we take N samples of X()
at equally spaced frequencies {
k
= 2k/N, k = 0, 1, ..., N1}, along the interval [0, 2),
the resulting samples are (Figure)
X(k)
|
.
|

\
|
N
k
X
t 2
=

1
0
/ 2
) (
N
n
N n k j
e n x
t
,
Since these frequency samples are obtained by evaluating the Fourier transform X() at N
equally spaced discrete frequencies, the above relation is called the discrete Fourier transform
(DFT) of x(n). In other words, X(k) are discrete samples of the continuous X().

The corresponding inverse discrete Fourier transform (IDFT) is given by
x(n) =
N
1

=
1
0
/ 2
) (
N
k
N n k j
e k X
t
, n = 0, 1, , N1

Example 2.4.1 Find the DFT of the unit sample x(n) = {1, 0, 0, 0}. (Aside. What is the DTFT of
x(n) = {1, 0, 0, 0}?)


Solution The number of samples is N = 4. The DFT is given by
X(k) =

1
0
/ 2
) (
N
n
N n k j
e n x
t
, 0 s k s N1
N samples of X()
X()
2t
N
0
0

2 t/N
1 N1
Sequence
x(n) = {1, 0, 0, 0}
2 0
n
1 3
N1
4
N
1
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 8 of 53 Dr. Ravi Billa
=

1 4
0
4 / 2
) (
n
n k j
e n x
t
, 0 s k s 3
=

3
0
4 / 2
) (
n
n k j
e n x
t
, k = 0, 1, 2, 3

3
0
4 / 2
) (
n
n k j
e n x
t
, k = 0, 1, 2, 3
k = 0
X(0) =

3
0
4 / 2 . 0
) (
n
n j
e n x
t
=

=
3
0
1 . ) (
n
n x =

=
3
0
) (
n
n x
= x(0) + x(1) + x(2) + x(3) = 1 + 0 + 0 + 0 = 1
k = 1
X(1) =

3
0
4 / 2 . 1
) (
n
n j
e n x
t
=

3
0
2 /
) (
n
n j
e n x
t
= x(0) e
j 0
= 1 . 1 = 1
k = 2
X(2) =

3
0
4 / 2 . 2
) (
n
n j
e n x
t
=

3
0
) (
n
n j
e n x
t
= x(0) e
j 0
= 1 . 1 = 1
k = 3
X(3) =

3
0
4 / 2 . 3
) (
n
n j
e n x
t
=

3
0
2 / 3
) (
n
n j
e n x
t
= x(0) e
j 0
= 1 . 1 = 1

The DFT is X(k) = {1, 1, 1, 1} and contains all (four) frequency components. In this example
X(k) is real-valued.
In MATLAB use fft(x) for the DFT. The magnitude and phase plots of X(k) and the
program segment follow.

0 0.5 1 1.5 2 2.5 3
0
0.5
1
k
M
a
g
n
i
t
u
d
e
4-point DFT of {1, 0, 0, 0}
0 0.5 1 1.5 2 2.5 3
-1
-0.5
0
0.5
1
k
P
h
a
s
e

x= [1, 0, 0, 0]; X= fft(x);
Mag = abs(X); Phase = angle(X);
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 9 of 53 Dr. Ravi Billa
k=0:3;
subplot(2, 1, 1), stem(k, Mag, 'bo'); %Two rows, one column, #1
xlabel ('k'), ylabel('Magnitude');
title ('4-point DFT of \{1, 0, 0, 0\}')
grid;
subplot(2, 1, 2), stem(k, Phase, 'bo'); %Two rows, one column, #2
xlabel ('k'), ylabel('Phase');

Matrix formulation To facilitate computation the DFT equations may be arranged as a matrix-
vector multiplication. We define the twiddle factor
N
W =
N j
e
/ 2t
, which for N = 4 becomes
4
W =
4 / 2t j
e

. The equations are rewritten using the twiddle factor


X(k) =

3
0
4 / 2
) (
n
n k j
e n x
t
=

=
3
0
4
) (
n
n k
W n x , k = 0, 1, 2, 3
There are a total of 4 values of X(.) ranging from X(0) to X(3):

) 0 ( X =
0
4
) 0 ( W x +
0
4
) 1 ( W x +
0
4
) 2 ( W x +
0
4
) 3 ( W x
) 1 ( X =
0
4
) 0 ( W x +
1
4
) 1 ( W x +
2
4
) 2 ( W x +
3
4
) 3 ( W x
) 2 ( X =
0
4
) 0 ( W x +
2
4
) 1 ( W x +
4
4
) 2 ( W x +
6
4
) 3 ( W x
) 3 ( X =
0
4
) 0 ( W x +
3
4
) 1 ( W x +
6
4
) 2 ( W x +
9
4
) 3 ( W x

These equations can be put in matrix from:

(
(
(
(

) 3 (
) 2 (
) 1 (
) 0 (
X
X
X
X
=
(
(
(
(
(

9
4
6
4
3
4
6
4
4
4
2
4
3
4
2
4
1
4
1
1
1
1 1 1 1
W W W
W W W
W W W

(
(
(
(

) 3 (
) 2 (
) 1 (
) 0 (
x
x
x
x

This last form is perhaps the most convenient to perform the actual computations by plugging in
the twiddle factors
m
W
4
and the signal values x(.). Note that


) 2 / ( N k
N
W
+
=
k
N
W and
k mN
N
W
+
=
k
N
W
and


1
4
W =
4 / 2t j
e

= j,
2
4
W =
2
) ( j = 1,
3
4
W =
3
) ( j = j, etc.

The above matrix form then can be written,

(
(
(
(

) 3 (
) 2 (
) 1 (
) 0 (
X
X
X
X
=
(
(
(
(




j j
j j
1 1
1 1 1 1
1 1
1 1 1 1

(
(
(
(

0
0
0
1
=
(
(
(
(

1
1
1
1


Example 2.4.2 Find the DFT of the dc sequence x(n) = {1, 1, 1, 1}. (Aside. What is the DTFT
of x(n) = {1, 1, 1, 1}? Give 4 samples of X() at intervals of 2/4 starting at = 0.) (Compare
Proakis, 3
rd
Ed., Ex. 5.1.2)
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 10 of 53 Dr. Ravi Billa


Solution The number of samples is N = 4. The DFT is given by
X(k) =

1
0
/ 2
) (
N
n
N n k j
e n x
t
, 0 s k s N1
=

3
0
4 / 2
) (
n
n k j
e n x
t
, k = 0, 1, 2, 3

X(k) ==

3
0
4 / 2
) (
n
n k j
e n x
t
, k = 0, 1, 2, 3
k = 0
X(0) =

3
0
4 / 2 . 0
) (
n
n j
e n x
t
=

=
3
0
1 . ) (
n
n x =

=
3
0
) (
n
n x
= x(0) + x(1) + x(2) + x(3) = 1 + 1 + 1 + 1 = 4
k = 1
X(1) =

3
0
4 / 2 . 1
) (
n
n j
e n x
t
=

3
0
2 /
) (
n
n j
e n x
t
=

3
0
2 /
) ( . 1
n
n j
e
t
=

=

3
0
) (
n
n
j
= 1 j + (j)
2
+ (j)
3
= 1 j + j
2
j
3
= 1 j 1 + j = 0
k = 2
X(2) =

3
0
4 / 2 . 2
) (
n
n j
e n x
t
=

3
0
) ( . 1
n
n j
e
t
= 1 1 + 1 1 = 0
k = 3
X(3) =

3
0
4 / 2 . 3
) (
n
n j
e n x
t
=

3
0
2 / 3
. 1
n
n j
e
t
= 1+ j 1 j = 0

The DFT is X(k) = {4, 0, 0, 0} and contains only the dc component and no other. Here again
X(k) is real-valued.

Sequence
x(n) = {1, 1, 1, 1}
2 0
n
1
3
N1
4
N
1
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 11 of 53 Dr. Ravi Billa
Example 2.4.3 Find the DFT of the sequence x(n) = {1, 0, 0, 1}

Solution The number of samples is N = 4. The DFT is given by
X(k) =

1
0
/ 2
) (
N
n
N n k j
e n x
t
, 0 s k s N1
=

3
0
4 / 2
) (
n
n k j
e n x
t
, k = 0, 1, 2, 3

X(k) =

3
0
4 / 2
) (
n
n k j
e n x
t
, k = 0, 1, 2, 3
k = 0
X(0) =

3
0
4 / 2 . 0
) (
n
n j
e n x
t
=

=
3
0
1 . ) (
n
n x =

=
3
0
) (
n
n x
= x(0) + x(1) + x(2) + x(3) = 1 + 0 + 0 + 1 = 2
k = 1
X(1) =

3
0
4 / 2 . 1
) (
n
n j
e n x
t
=

3
0
2 /
) (
n
n j
e n x
t
=
n
n
j
e n x ) ( ) (
3
0
2 /

=
t
=
n
n
j n x ) ( ) (
3
0

=

= 1 . 1 + 0 + 0 + 1 . (j)
3
= 1 + j = 2 e
j t / 4
= 2 4 / t Z
k = 2
X(2) =

3
0
4 / 2 . 2
) (
n
n j
e n x
t
=

3
0
) (
n
n j
e n x
t
= x(0) e
j 0
+ x(3) e
j3

= 1 . 1 + 1 . (1) = 0
k = 3
X(3) =

3
0
4 / 2 . 3
) (
n
n j
e n x
t
=

3
0
2 / 3
) (
n
n j
e n x
t
= x(0) e
j 0
+ x(3) e
j 33 / 2



= 1 . 1 + 1 . (j) = 1 j = 2 e
j t / 4
= 2 4 / t Z

The DFT is X(k) = {2,
4 /
2
t j
e , 0,
4 /
2
t j
e

}. In general X(k) is complex-valued and has a


magnitude and a phase. See figure.
In MATLAB use fft(x) for the DFT and ifft(X) for the IDFT. The magnitude and phase
plots and the program segment follow.

x = [1, 0, 0, 1]; X = fft(x); Mag = abs(X); Phase = angle(X);
k = 0:3;
subplot(2, 1, 1), stem(k, Mag, 'bo'); %Two rows, one column, #1
Sequence
x(n) = {1, 0, 0, 1}
2 0
n
1
3
N1
4
N
1
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 12 of 53 Dr. Ravi Billa
xlabel ('k'), ylabel('Magnitude');
title ('4-point DFT of \{1, 0, 0, 1\}')
grid;
subplot(2, 1, 2), stem(k, Phase, 'bo'); %Two rows, one column, #2
xlabel ('k'), ylabel('Phase');


0 0.5 1 1.5 2 2.5 3
0
0.5
1
1.5
2
k
M
a
g
n
i
t
u
d
e
4-point DFT of {1, 0, 0, 1}
0 0.5 1 1.5 2 2.5 3
-1
-0.5
0
0.5
1
k
P
h
a
s
e



www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 13 of 53 Dr. Ravi Billa



The frequency components {X(k), k = 0, 1, 2, 3} are harmonics. The spacing between
successive components, denoted by F
0
, is the resolution of the DFT and is given by F
0
= F
s
/N:
it is the sampling interval in the frequency domain. It is determined by the sampling frequency F
s

or sampling interval T in the time domain (F
s
= 1/T) and the number of samples, N. Note that N
is the number of time domain samples as well as the number of frequency domain samples.

|X(k)|
2 0
k
1 3
N1
4
N
2
DFT of x(n) = {1, 0, 0, 1}
2

2

One period. Corresponds to:
1. = 0 to 2 radians, or
2. = 0 to
s
rad/sec, or
3. F = 0 to F
s
Hz, or
4. A sequence length of N (= 4)
) (k X Z
2 0
k
1
3
4
N
/4
/4
/4
/4
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 14 of 53 Dr. Ravi Billa
Record length, sampling time and frequency resolution of the DFT We shall use Example 3
above to illustrate. Suppose that the sampling frequency is 8000 Hz, then the sampling time is T
= (1/8000) sec = 125 sec. The time domain samples x(n) are spaced 125 sec apart. In the
frequency domain the DFT values, X(k), are spaced (8000/4) = 2000 Hz apart. The DFT
spectrum is re-plotted below with these parameters.


















The terms introduced in this example and their interrelationships are summarized below:

Record length (one period) = T
0
seconds = N samples
Sampling interval = T seconds = 1/F
s

Sampling interval = T sec = (T
0
/N) seconds

Sampling frequency (one period) = F
s
Hz
Frequency resolution of the DFT = F
0
Hz = 1/T
0

Frequency resolution of the DFT = F
0
Hz = (F
s
/N) Hz

T = 125 sec
4 = N n 0 2 1 3
1 1
x(n)
One complete period = T
0
= 500 sec
500 Time, sec 0 250 125 375
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 15 of 53 Dr. Ravi Billa
The situation in the frequency domain is shown below.












































F, Hz 0 2000 4000 6000 8000
= F
s

= 2F, rad/sec 0 2 4000 2 8000
Digital Frequency,
= T, rad/sample
0 2
4 = N k
0 2 1
3
2
|X(k)|
One complete period = F
s
= 8 kHz
2

2

F
0
= 2 kHz
Center of Even Symmetry = N/2
4 = N k
0 2 1
3
( ) k X Z

/4
/4
Center of Odd Symmetry = N/2
Undefined
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 16 of 53 Dr. Ravi Billa
Example 2.4.4 [2003] Find the inverse discrete Fourier transform of X(k) = {3, (2+j), 1, (2j)}.
Solution The number of samples is N = 4. The IDFT is given by the synthesis equation
x(n) =
N
1

=
1
0
/ 2
) (
N
k
N n k j
e k X
t
, n = 0, 1, , N1
=
4
1

=
3
0
4 / 2
) (
k
n k j
e k X
t
,
=
4
1

=
3
0
2 /
) (
k
n k j
e k X
t
, 0 s n s 3
The calculations for {x(n), n = 0 to 3} are shown in table below.

x(n) =
4
1

=
3
0
2 /
) (
k
n k j
e k X
t

n = 0
x(0) =
4
1

=
3
0
2 / 0
) (
k
k j
e k X
t
=
4
1

=
3
0
) (
k
k X
= (1/4) {X(0) + X(1) + X(2) + X(3)} = (1/4) {3 + 2+j + 1 + 2j} = 2
n = 1
x(1) = (1/4)

=
3
0
2 / 1
) (
k
k j
e k X
t
= (1/4) ( )

=
3
0
2 /
) (
k
k
j
e k X
t
= (1/4) ( )

=
3
0
) (
k
k
j k X
= (1/4) {X(0) (j)
0
+ X(1) (j)
1
+ X(2) (j)
2
+ X(3) (j)
3
}
= (1/4) {3 . 1 + (2+j) . j + 1 . (1) + (2j) . (j)} = 0
n = 2
x(2) = (1/4)

=
3
0
2 / 2
) (
k
k j
e k X
t
= (1/4)

=
3
0
) (
k
k j
e k X
t
= (1/4) ( )

=

3
0
1 ) (
k
k
k X
= (1/4) {X(0) (1) + X(1) (1) + X(2) (1) + X(3) (1)}
= (1/4) {X(0) X(1) + X(2) X(3)}
= (1/4) {3 (2+j) + 1 . (1) (2j)} = 0
n = 3
x(3) = (1/4)

=
3
0
2 / 3
) (
k
k j
e k X
t
= (1/4) ( )

=
3
0
2 / 3
) (
k
k
j
e k X
t
= (1/4)

=

3
0
) ( ) (
k
k
j k X
= (1/4) {3 . 1 + (2+j). (j) + 1 . (1) + (2j). j}
= (1/4) {3 j2 + 1 1 + j2 + 1} = 1

Thus x(n) = {2, 0, 0, 1}.
In MATLAB use ifft(X) for the IDFT. The magnitude and phase plots of x(n) and the
program segment follow.

X = [3, (2+j), 1, (2-j)]; x = ifft(X); Mag = abs(x); Phase = angle(x);
n = 0:3;
subplot(2, 1, 1), stem(n, Mag, 'bo'); %Two rows, one column, #1
xlabel ('n'), ylabel('Magnitude');
title ('4-point IDFT of \{3, (2+j), 1, (2-j)\}')
grid;
subplot(2, 1, 2), stem(n, Phase, 'bo'); %Two rows, one column, #2
xlabel ('n'), ylabel('Phase');



www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 17 of 53 Dr. Ravi Billa
0 0.5 1 1.5 2 2.5 3
0
0.5
1
1.5
2
n
M
a
g
n
i
t
u
d
e
4-point IDFT of {3, (2+j), 1, (2-j)}
0 0.5 1 1.5 2 2.5 3
-1
-0.5
0
0.5
1
n
P
h
a
s
e


Matrix formulation Here again to facilitate computation the IDFT equations may be arranged
as a matrix-vector multiplication.
x(n) =
4
1

=
3
0
4 / 2
) (
n
n k j
e k X
t
=
4
1
( )

=
3
0
*
4
) (
n
kn
W k X , n = 0, 1, 2, 3
There are a total of 4 values of x(.) ranging from x(0) to x(3):

(
(
(
(

) 3 (
) 2 (
) 1 (
) 0 (
x
x
x
x
=
4
1
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
(
(
(
(
(

9
*
4
6
*
4
3
*
4
6
*
4
4
*
4
2
*
4
3
*
4
2
*
4
1
*
4
1
1
1
1 1 1 1
W W W
W W W
W W W

(
(
(
(

) 3 (
) 2 (
) 1 (
) 0 (
X
X
X
X

This last form is perhaps the most convenient to perform the actual computations by plugging in
the twiddle factors ( )
m
W
*
4
and the values X(.). The above matrix form then can be written,

(
(
(
(

) 3 (
) 2 (
) 1 (
) 0 (
x
x
x
x
=
4
1
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
(
(
(
(
(

9
*
4
6
*
4
3
*
4
6
*
4
4
*
4
2
*
4
3
*
4
2
*
4
1
*
4
1
1
1
1 1 1 1
W W W
W W W
W W W

(
(
(
(

+
j
j
2
1
2
3


www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 18 of 53 Dr. Ravi Billa
Example 2.4.5 [N not an integral power of 2] Using MATLAB find the 5-point DFT of

x(n) = {1, 0, 0, 0, 0}
Solution

x = [1, 0, 0, 0, 0]; X = fft(x),
Mag = abs(X); Phase = angle(X);
k = 0:4;
subplot(2, 1, 1), stem(k, Mag, 'bo'); %Two rows, one column, #1
xlabel ('k'), ylabel('Magnitude');
title ('5-point DFT of \{1, 0, 0, 0, 0\}')
grid;
subplot(2, 1, 2), stem(k, Phase, 'bo'); %Two rows, one column, #2
xlabel ('k'), ylabel('Phase');

0 0.5 1 1.5 2 2.5 3 3.5 4
0
0.5
1
k
M
a
g
n
i
t
u
d
e
5-point DFT of {1, 0, 0, 0, 0}
0 0.5 1 1.5 2 2.5 3 3.5 4
-1
-0.5
0
0.5
1
k
P
h
a
s
e


www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 19 of 53 Dr. Ravi Billa
Example 2.4.6 [N not an integral power of 2] Using MATLAB find the 6-point IDFT of

X(k) = {6, 0, 0, 0, 0, 0}
Solution

X = [6, 0, 0, 0, 0, 0]; x = ifft(X); Mag = abs(x); Phase = angle(x);
n = 0:5;
subplot(2, 1, 1), stem(n, Mag, 'bo'); %Two rows, one column, #1
xlabel ('n'), ylabel('Magnitude');
title ('6-point IDFT of \{6, 0, 0, 0, 0, 0\}')
grid;
subplot(2, 1, 2), stem(n, Phase, 'bo'); %Two rows, one column, #2
xlabel ('n'), ylabel('Phase');

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0
0.5
1
n
M
a
g
n
i
t
u
d
e
6-point IDFT of {6, 0, 0, 0, 0, 0}
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-1
-0.5
0
0.5
1
n
P
h
a
s
e

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 20 of 53 Dr. Ravi Billa
Example 2.4.7 [2008, 2009] Consider a sequence x(n) = {2, 1, 1, 1} and the sampling time T =
0.5 sec. Compute its DFT and compare it with its DTFT.
Solution The record length of the sequence is T
0
= 4T = 2 sec.
The DFT is a sequence of 4 values given by
X(k) =

3
0
4 / 2
) (
n
n k j
e n x
t
, k = 0, 1, 2, 3
The periodicity of X(k) is 4. The frequency resolution of the DFT is 1/T
0
= 0.5 Hz.
The DTFT, X(), is a continuous function of
X() =

n
n j
e n x
e
) ( =

3
0
) (
n
n j
e n x
e
= 2
0 j
e 1
e j
e

+1
e 2 j
e

+1
e 3 j
e


= 2
e j
e

+
e 2 j
e

+
e 3 j
e



The periodicity of X(), in terms of , is 2t. In terms of the Hertz frequency the periodicity is
the sampling frequency = F
s
= 1/T = 2 Hz.
The DFT is a sampled version of the DTFT, sampled at 4 points along the frequency axis
spaced 0.5 Hz apart.
You should evaluate completely both X(k) (a set of 4 numbers) and X() (magnitude and
phase). Note that X() may be evaluated directly at e = 0, t/2, t, and 3t/2 by plugging in the e
values into the expression given above; these are then the DFT numbers as well. The MATLAB
solutions are given below.
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 21 of 53 Dr. Ravi Billa
In MATLAB: The magnitude and phase plots of the DFT can be generated by the following
segment:

x = [2, -1, 1, 1]; X = fft(x); Mag = abs(X); Phase = angle(X);
k = 0:3;
subplot(2, 1, 1), stem(k, Mag, 'bo'); %Two rows, one column, #1
xlabel ('k'), ylabel('Magnitude');
title ('4-point DFT of \{2, -1, 1, 1\}')
grid;
subplot(2, 1, 2), stem(k, Phase, 'bo'); %Two rows, one column, #2
xlabel ('k'), ylabel('Phase');

The MATLAB solution:
X = 3, (1 + j2), 3, (1 - j2)
Mag = 3, 2.2361, 3, 2.2361
Phase = 0, 1.1071, 0, -1.1071


0 0.5 1 1.5 2 2.5 3
0
1
2
3
k
M
a
g
n
i
t
u
d
e
4-point DFT of {2, -1, 1, 1}
0 0.5 1 1.5 2 2.5 3
-2
-1
0
1
2
k
P
h
a
s
e


www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 22 of 53 Dr. Ravi Billa
The magnitude and phase plots of the DTFT can be generated by the following segment:

b = [2, -1, 1, 1]; %Numerator coefficients
a = [1]; %Denominator coefficient
w = 0: pi/256: 2*pi; %A total of 512 points
[h] = freqz(b, a, w);
subplot(2, 1, 1), plot(w/pi, abs(h));
xlabel('Frequency, Hz'), ylabel('Magnitude'); grid
title ('4-point DTFT of \{2, 1, 1, 1\}')
subplot(2, 1, 2), plot(w/pi, angle(h));
xlabel('Frequency, Hz'), ylabel('Phase - Radians'); grid

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
1
2
3
4
Frequency, Hz
M
a
g
n
i
t
u
d
e
4-point DTFT of {2, 1, 1, 1}
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-2
-1
0
1
2
Frequency, Hz
P
h
a
s
e

-

R
a
d
i
a
n
s


Example 2.4.8 [2008] Compute the discrete Fourier transform of the following finite length
sequences considered to be of length N.
1) x(n) = (n+n
0
), 0 < n
0
< N
2) x(n) = a
n
, 0 < a < 1
Solution See Ramesh Babu 3.16.
Note that x(n) = (n+n
0
) would be zero everywhere except at n = n
0
which is not in the
range [0, N). So make it (nn
0
).

Example 2.4.9 [2008] Compute the N-point DFT X(k) of the sequence
x(n) = cos (2tn/N), 0 n N1
for 0 k N1.
Solution Express cos (2tn/N) as 2 / ) (
/ 2 / 2 N n j N n j
e e
t t
+ .

Example 2.4.10 Obtain the 7-point DFT of the sequence x(n) = {1, 2, 3, 4, 3, 2, 1} by taking 7
samples of its DTFT uniformly spaced over the interval 0 2.
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 23 of 53 Dr. Ravi Billa
Solution The sampling interval in the frequency domain is 2/7. From Example 4 we have
) (
e j
e X or X() = 1+
1
2
e j
e

+
2
3
e j
e

+
3
4
e j
e

+
4
3
e j
e

+
5
2
e j
e

+
6
1
e j
e


= (2 e 3 cos +4 e 2 cos +6 e cos +4)
e 3 j
e


The DFT, ) (k X , is given by replacing with k(2/7) where k is an index ranging from 0 to 6:
DFT =
7 / 2
) (
k
X
t e
e
=
= ) 7 / 2 ( k X t , k = 0 to 6
This is denoted XkfromDTFT in the MATLAB segment below.

MATLAB:
w = 0: 2*pi/7: 2*pi-0.001
XkfromDTFT = (4+6*cos(w)+4*cos(2*w)+2*cos(3*w)) .* exp(-j*3*w)

MATLAB solution:

XkfromDTFT = [16, (-4.5489 - 2.1906i), (0.1920 + 0.2408i), (-0.1431 - 0.6270i),
(-0.1431 + 0.6270i), (0.1920 - 0.2408i), (-4.5489 + 2.1906i)]

This is the 7-point DFT obtained by sampling the DTFT at 7 points uniformly spaced in (0, 2).
It should be the same as the DFT directly obtained, for instance, by using the fft function in
MATLAB:

MATLAB:
xn = [1 2 3 4 3 2 1]
Xkusingfft = fft(xn)

MATLAB solution:

Xkusingfft = [16, (-4.5489 - 2.1906i), (0.1920 + 0.2408i), (-0.1431 - 0.6270i),
(-0.1431 + 0.6270i), (0.1920 - 0.2408i), (-4.5489 + 2.1906i)]

It can be seen that XkfromDTFT = Xkusingfft.

Example 2.4.11 Obtain the 7-point inverse DTFT x(n) by finding the 7-point inverse DFT of
X(k):

) 7 / 2 ( k X t = [16, (-4.5489 - 2.1906i), (0.1920 + 0.2408i), (-0.1431 - 0.6270i),
(-0.1431 + 0.6270i), (0.1920 - 0.2408i), (-4.5489 + 2.1906i)]

MATLAB:

Xk = [16, (-4.5489 - 2.1906i), (0.1920 + 0.2408i), (-0.1431 - 0.6270i),(-0.1431 +
0.6270i), (0.1920 - 0.2408i), (-4.5489 + 2.1906i)]
xn = ifft(Xk)

MATLAB solution:

xn = [1.0000 2.0000 3.0000 4.0000 3.0000 2.0000 1.0000]

This is the original sequence we started with in Example 4.

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 24 of 53 Dr. Ravi Billa
Example 2.4.12 What will be the resulting time sequence if the DTFT of the 7-point sequence is
sampled at 6 (or fewer) uniformly spaced points in (0, 2) and its inverse DFT is obtained?
Solution The sampling interval in the frequency domain now is 2/6. From Example 4 we have

) (
e j
e X or X() = 1+
1
2
e j
e

+
2
3
e j
e

+
3
4
e j
e

+
4
3
e j
e

+
5
2
e j
e

+
6
1
e j
e


= (2 e 3 cos +4 e 2 cos +6 e cos +4)
e 3 j
e



The DFT then is given by

DFT =
6 / 2
) (
k
X
t e
e
=
= ) 6 / 2 ( k X t , k = 0 to 5

This is denoted Xk6point in the MATLAB segment below.

MATLAB:
w = 0: 2*pi/6: 2*pi-0.001
Xk6point = (4+6*cos(w)+4*cos(2*w)+2*cos(3*w)) .* exp(-j*3*w)

MATLAB solution:
Xk6point = [16, (-3.0000 - 0.0000i), (1.0000 + 0.0000i), 0, (1.0000 + 0.0000i),
(-3.0000 - 0.0000i)]

This is the 6-point DFT obtained by sampling the DTFT at 6 points uniformly spaced in (0, 2).

Example 2.4.13 Obtain the 6-point inverse DTFT x(n) by finding the 6-point inverse DFT of
Xk6point:

) 6 / 2 ( k X t = [16, (-3.0000 - 0.0000i), (1.0000 + 0.0000i), 0, (1.0000 + 0.0000i),
(-3.0000 - 0.0000i)]

MATLAB:

Xk6point = [16, (-3.0000 - 0.0000i), (1.0000 + 0.0000i), 0, (1.0000 + 0.0000i), (-
3.0000 - 0.0000i)]
xn = ifft(Xk6point)

MATLAB solution:

xn = [2 2 3 4 3 2]

Comparing with the original 7-point sequence, xn = [1 2 3 4 3 2 1], we see the
consequence of under-sampling the continuous- function X(): the corresponding time domain
sequence x(n) is said to suffer time-domain aliasing. This is similar to the situation that occurs
when a continuous-time function x(t) is under-sampled: the corresponding frequency domain
function ) (e
s
X contains frequency-domain aliasing.

Example 2.4.14 What will be the resulting time sequence if the DTFT of the 7-point sequence is
sampled at 8 (or more) uniformly spaced points in (0, 2) and its inverse DFT is obtained?
Solution The sampling interval in the frequency domain now is 2/8. From Example 4 we have

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 25 of 53 Dr. Ravi Billa
) (
e j
e X or X() = 1+
1
2
e j
e

+
2
3
e j
e

+
3
4
e j
e

+
4
3
e j
e

+
5
2
e j
e

+
6
1
e j
e


= (2 e 3 cos +4 e 2 cos +6 e cos +4)
e 3 j
e



The DFT then is given by

DFT =
8 / 2
) (
k
X
t e
e
=
= ) 8 / 2 ( k X t , k = 0 to 7

This is denoted Xk8point in the MATLAB segment below.

MATLAB:
w = 0: 2*pi/8: 2*pi-0.001
Xk8point = (4+6*cos(w)+4*cos(2*w)+2*cos(3*w)) .* exp(-j*3*w)

MATLAB solution:

Xk8point = [16, (-4.8284 - 4.8284i), (0.0000 - 0.0000i), (0.8284 - 0.8284i), 0,
(0.8284 + 0.8284i), (0.0000 - 0.0000i), (-4.8284 + 4.8284i)]

This is the 8-point DFT obtained by sampling the DTFT at 8 points uniformly spaced in (0, 2).

Example 2.4.15 Obtain the 8-point inverse DTFT x(n) by finding the 8-point inverse DFT of
Xk8point:

) 8 / 2 ( k X t = [16, (-4.8284 - 4.8284i), (0.0000 - 0.0000i), (0.8284 - 0.8284i), 0,
(0.8284 + 0.8284i), (0.0000 - 0.0000i), (-4.8284 + 4.8284i)]

MATLAB:

Xk8point = [16, (-4.8284 - 4.8284i), (0.0000 - 0.0000i), (0.8284 - 0.8284i), 0,
(0.8284 + 0.8284i), (0.0000 - 0.0000i), (-4.8284 + 4.8284i)]
xn = ifft(Xk8point)

MATLAB solution:

xn = [1 2 3 4 3 2 1 0]

We see that the original 7-point sequence has been preserved with an appended zero. The
original sequence and the zero-padded sequence (with any number of zeros) have the same
DTFT. This is a case of over-sampling the continuous- function X(): there is no time-domain
aliasing. This is similar to the situation that occurs when a continuous-time function x(t) is over-
sampled: the corresponding frequency domain function ) (e
s
X is free from frequency-domain
aliasing.

%Sketch of sequences
n = 0:1:6; xn = [1, 2, 3, 4, 3, 2, 1];
subplot (3, 1, 1), stem(n, xn)
xlabel('n'), ylabel('x(n)-7point'); grid
%
n = 0:1:5; xn = [2 2 3 4 3 2];
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 26 of 53 Dr. Ravi Billa
subplot (3, 1, 2), stem(n, xn)
xlabel('n'), ylabel('x(n)-6point'); grid
%
n = 0:1:7; xn = [1, 2, 3, 4, 3, 2, 1, 0];
subplot (3, 1, 3), stem(n, xn)
xlabel('n'), ylabel('x(n)-8point'); grid

0 1 2 3 4 5 6
0
2
4
n
x
(
n
)
-
7
p
o
i
n
t
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0
2
4
n
x
(
n
)
-
6
p
o
i
n
t
0 1 2 3 4 5 6 7
0
2
4
n
x
(
n
)
-
8
p
o
i
n
t



www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 27 of 53 Dr. Ravi Billa
2.5 Properties of DFT

The properties of the DFT (for finite duration sequences) are essentially similar to those of the
DFS for periodic sequences and result from the implied periodicity in the DFT representation.

(1) Periodicity If x(n) and X(k) are an N-point DFT pair, then X(k) (and x(n)) is periodic with a
periodicity of N. That is

X(k+N) = X(k) for all k

This can be proved by replacing k by k+N in the defining equation for X(k).

(2) Linearity For two sequences x
1
(n) and x
2
(n) defined on [0, N1], if x
3
(n) = a x
1
(n) + b x
2
(n)
then

DFT {x
3
(n)} = DFT {a x
1
(n) + b x
2
(n)} = a DFT {x
1
(n)} + b DFT {x
2
(n)}

If one of the two sequences x
1
(n) and x
2
(n) is shorter than the other then the shorter one must be
padded with zeros to make both sequences of the same length.

(3) Circular shift or circular translation of a sequence (The sequence wraps around). The
circular shift, by an amount n
0
to the right, of the sequence x(n) defined on [0, N1] is denoted by
x((nn
0
)
mod N
) or x((nn
0
))
N
. For example, if x(n) is

x(n) = {x(0), x(1), x(2), , x(N3), x(N2), x(N1)}

then x((n2))
N
is given by

x((n2))
N
= {x(N2), x(N1), x(0), x(1), x(2), , x(N3)}

The operation can be thought of as wrapping the part that falls outside the region of interest
around to the front of the sequence, or equivalently, just a straight (linear) translation of its
periodic extension.


Example 2.5.1 Given x(n) = {1, 2, 2, 0}. Here N = 4. The circular shift of x(n) by one unit to the
right is x((n1))
4
, and is given by

x((n1))
4
= {0, 1, 2, 2}

where the 0 has been wrapped around to the start and the other values are shifted one unit to the
right.
Alternatively, we can view this as a straight translation of the periodic extension outside
the range [0, 3] of the given sequence. The periodic extension x
p
(n) is shown below:

x
p
(n) = { 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, }

|
n=0


The periodic extension, when shifted to the right by one unit, appears as below; and the
circularly shifted version x((n1))
4
is the shaded part defined over 0 s n s 3 only:
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 28 of 53 Dr. Ravi Billa

x((n1))
4

x
p
(n 1) = { 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, }

|
n=0














































6 4 5 6 4 2
2
0
1
2 2
0
1
2 2
0
1
2
x
p
(n) (periodic extension)
n
0 1 2 3
2
0
1
2
x(n)
n
0 1 2 3
6 4 5 6 4 2
2
0
1
2 2
0
1
2 2
0
1
2
x
p
(n1) (shifted by 1)
n
0 1 2 3
2
0
1
2
x((n1))
4
(truncated outside [0, 3])
n
0 1 2 3
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 29 of 53 Dr. Ravi Billa
Example 2.5.2 Given x(n) = {1, 2, 2, 0}, sketch x((nk))
4
where k is the independent variable.
































DFT of circularly-shifted sequence Given that DFT {x(n)} = X(k), then
DFT {x((nm))
N
} =
m k
N
W X(k)
Conversely, if the X(k) is circularly shifted, the resulting inverse transform will be the
multiplication of the inverse of X(k) by a complex exponential: that is, if DFT {x(n)} = X(k), then
DFT {
n l
N
W

x(n)} = X((kl))
N

Note from the above property that a shift in the frequency domain values X(k) generally results in
a complex-valued inverse sequence x(n) even though the original sequence in the time domain
could have been real-valued.

Circular convolution The N-point circular convolution of two sequences x
1
(n) and x
2
(n) denoted
by x
1
(n)
N
x
2
(n) is defined as follows:

x
1
(n)
N
x
2
(n)

=

1
0
2 1
)) (( ) (
N
k
N
k n x k x =

=

1
0
2 1
) ( )) ((
N
k
N
k x k n x

0
5 4 5 6 4 2
2
0
1
2
1
2
0
1
2
x
p
(1k)
k
0 1 2 3
x((1k ))
4
= circular shift of
x(k) to the right by 1 unit
0
6 4 5 6 4 2
2
0
1
2
1
2
0
1
2
x
p
(0k)
k
0 1 2 3
x((0k ))
4
= circular shift of
x(k) to the right by 0 units
1
2
2
0
x(k)
x((k))
4

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 30 of 53 Dr. Ravi Billa
where x
1
((nk))
N
is the reflected and circularly translated version of x
1
(n). Note that k is the
independent variable, so that x
1
(k) is the reflected version and x
1
((kn))
N
is simply the
reflected version shifted right by n units; the mod N makes it a circular shift instead of a linear
shift.
If X
1
(k) and X
2
(k) represent the N-point DFTs of x
1
(n) and x
2
(n) respectively, i.e.,

X
1
(k) = DFT
N
{x
1
(n)} and X
2
(k) = DFT
N
{x
2
(n)}
Then

IDFT
N
{X
1
(k) X
2
(k)} = x
1
(n)
N
x
2
(n), or DFT
N
{x
1
(n)
N
x
2
(n)} = X
1
(k) X
2
(k)

This property is used to perform circular convolution of two sequences by first obtaining their
DFTs, multiplying the two DFTs, then taking the inverse DFT of the product.

Example 2.5.3 [Circular convolution] For the two sequences x
1
(n) = {1, 2, 2, 0} and x
2
(n) = {0,
1, 2, 3} find y(n) = x
1
(n)
4
x
2
(n).
Solution We use the form y(n) = x
1
(n)
N
x
2
(n) =

=

3
0
2 4 1
) ( )) ((
k
k x k n x which uses the circularly
shifted version x
1
((nk))
4
. The values of the sequence x
1
(k) = {1, 2, 2, 0} are arranged on a circle
in counterclockwise direction starting at point A. The sequence x
1
((k))
4
is then read off in the
clockwise direction starting at A. Thus x
1
((k))
4
= {1, 0, 2, 2}. See figure below.











As an alternative we may also obtain the sequence x
1
((k))
4
by periodically extending x
1
(k)
4
,
reflecting it about k = 0, and truncating it outside the range 0 k 3.
The value
y(0) =

=

3
0
2 4 1
) ( )) 0 ((
k
k x k x
is obtained by lining up x
1
((k))
4
below x
2
(k), multiplying and adding:

x
2
(k) 0 1 2 3
x
1
((k))
4
1 0 2 2

Thus y(0) = (0) (1) +(1) (0) +(2) (2) +(3) (2) = 10.
For n = 1 the value
y(1) =

=

3
0
2 4 1
) ( )) 1 ((
k
k x k x
is obtained as follows: the sequence x
1
((1k))
4
is obtained from x
1
((k))
4
by shifting the latter to
the right by 1 with wrap around; we then line up x
1
((1k))
4
below x
2
(k), multiply and add to get
y(1):
1
2
0
2 A
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 31 of 53 Dr. Ravi Billa

x
2
(k) 0 1 2 3
x
1
((1k))
4
2 1 0 2

The result is y(1) = (0) (2) +(1) (1) +(2) (0) +(3) (2) = 7.
The procedure is continued for successive values of n, at each step using the circularly-
shifted-by-1 version of the previous x
1
((nk))
4
.

Circular convolution Matrix method The circular convolution of the two sequences x
1
(n)
and x
2
(n) is given by:

x
1
(n)
N
x
2
(n)

=

1
0
2 1
) ( )) ((
N
k
N
k x k n x

- Step 1. By zero-padding make sure the two sequences are of the same length, say, N.
- Step 2. Arrange the various circularly shifted versions of x
1
(.) as a matrix and x
2
(.) as a
vector; then multiply to get the vector x
3
(.) which is the desired result.

The matrix formed by the shifted versions of x
1
(.) is shown below. It displays somewhat
more terms than is possible to show in the complete multiplication equation shown farther down
below.















(
(
(
(
(
(
(
(


) 0 ( ) 1 ( ) 2 ( . ) 3 ( ) 2 ( ) 1 (
) 1 ( ) 0 ( ) 1 ( . ) 4 ( ) 3 ( ) 2 (
. . . . . . .
) 3 ( ) 4 ( ) 5 ( . ) 0 ( ) 1 ( ) 2 (
) 2 ( ) 3 ( ) 4 ( . ) 1 ( ) 0 ( ) 1 (
) 1 ( ) 2 ( ) 3 ( . ) 2 ( ) 1 ( ) 0 (
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
x x x N x N x N x
N x x x N x N x N x
x x x x x x
x x x N x x x
x x x N x N x x


x
1
(0)
x
1
(1)
x
1
(2)
x
1
(3)
x
1
(N1)
x
1
(N2)
x
1
(N3)
Start
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 32 of 53 Dr. Ravi Billa
The complete multiplication step is shown below:

















(
(
(
(
(
(
(
(

) 0 ( ) 1 ( ) 2 ( . ) 2 ( ) 1 (
) 1 ( ) 0 ( ) 1 ( . ) 3 ( ) 2 (
. . . . . .
. . . . . .
) 2 ( ) 3 ( ) 4 ( . ) 0 ( ) 1 (
) 1 ( ) 2 ( ) 3 ( . ) 1 ( ) 0 (
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
x x x N x N x
N x x x N x N x
x x x x x
x x x N x x
(
(
(
(
(
(
(
(

) 1 (
) 2 (
.
.
) 1 (
) 0 (
2
2
2
2
N x
N x
x
x
=
(
(
(
(
(
(
(
(

) 1 (
) 2 (
.
.
) 1 (
) 0 (
3
3
3
3
N x
N x
x
x


As an example the element x
3
(0) is given by

x
3
(0) = x
1
(0) x
2
(0) + x
1
(N1) x
2
(1) + + x
1
(2) x
2
(N2) + x
1
(1) x
2
(N1)

x
2
0)
x
2
(1)
x
2
(2)
x
2
(3)
x
2
(N1)
x
2
(N2)
x
2
(N3)
Start
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 33 of 53 Dr. Ravi Billa
Carrying out circular convolution to obtain linear convolution If both signals x
1
(n) and x
2
(n)
are of finite lengths N
1
and N
2
respectively, and defined on [0, N
1
1] and [0, N
2
1], respectively,
as shown below, the value of N needed so that circular and linear convolution are the same on [0,
N1] can be shown to be N N
1
+ N
2
1.



Example 2.5.4 [Circular and linear convolution] (a) Determine the 4-point circular
convolution of the sequences

x
1
(n) = [1, 2, 3, 1] and x
2
(n) = [4, 3, 2, 1]

(b) Evaluate the linear convolution of the above sequences.
(c) Evaluate the linear convolution of the above sequences using circular convolution.
Solution
(a) The 4-point circular convolution is given by

y(n) = x
1
(n)
4
x
2
(n) = {15, 16, 21, 18}

(b) The linear convolution was done in Unit I:

y(n) = x
1
(n) * x
2
(n) = {4, 11, 20, 18, 11, 5, 1}

(c) Length of sequence x
1
(n) = N
1
= 4; length of sequence x
2
(n) = N
2
= 4. Let N = N
1
+ N
2
1 = 4
+ 4 1 = 7 be the length of each of the zero-padded sequences (.)
1
x' and (.)
2
x' .
x
1
(n)
N
x
2
(n)

=

1
0
2 1
) ( )) ((
N
k
N
k x k n x

Example 2.5.5 [2007] Compute the circular convolution of the sequences x
1
(n) = {1, 2, 0, 1} and
x
2
(n) = {2, 2, 1, 1} using the DFT approach.
Solution The sequences are of the same length, so no zero padding is needed. The length of
{x
1
(n)
N
x
2
(n)} is 4 (= N). Use the property that if x
1
(n) X
1
(k) and x
2
(n) X
2
(k) and x
3
(n) =
x
1
(n)
N
x
2
(n), then x
3
(n) X
3
(k) = X
1
(k) X
2
(k):

x
3
(n) = x
1
(n)
N
x
2
(n) = IDFT{X
3
(k)} = IDFT
N
{X
1
(k) X
2
(k)}with N = 4

where X
1
(k) and X
2
(k) are the N-point DFTs of x
1
(n) and x
2
(n), respectively. The following steps
are involved in computing x
1
(n)
N
x
2
(n):

1. Find X
1
(k) = DFT
4
{ x
1
(n)} and X
2
(k) = DFT
4
{ x
2
(n)}
2. Compute the product X
1
(k) X
2
(k)
x
1
(n)
n
N
1
1 0 N1
Zero
padding
x
2
(n)
n
N
2
1 0 N1
Zero
padding
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 34 of 53 Dr. Ravi Billa
3. Compute x
1
(n)
N
x
2
(n) = IDFT{X
1
(k) X
2
(k)}

Example 2.5.6 Compute the linear convolution of the sequences x(n) = {1, 2, 0, 1} and y(n) =
{2, 2, 1, 1} using the DFT approach.
Solution The length of x(n)*y(n) is 7 (= 4+41). We zero-pad the sequences to a length of 7 each
and perform circular convolution of the 7-point sequences; the result will be the same as the
linear convolution of the original 4-point sequences. The following steps are involved in
computing x(n)*y(n):

1. Augment the sequences x(.) and y(.) by zero-padding: x
a
(n) = {1, 2, 0, 1, 0, 0, 0}
and y
a
(n) = {2, 2, 1, 1, 0, 0, 0}
2. Find X
a
(k) = DFT
7
{x
a
(n)} and Y
a
(k) = DFT
7
{y
a
(n)}.
3. Compute the product X
a
(k) Y
a
(k)
4. Compute x(n)*y(n) = x(n)
7
y(n) = IDFT{X(k) Y(k)}

Example 2.5.7 Compute the linear convolution of the sequences x(n) = {1, 2} and y(n) = {2, 2,
1} using the DFT approach.
Solution The length of x(n)*y(n) is 4 (= 2+31). We zero-pad the sequences to a length of 4 each
and perform circular convolution of the 4-point sequences; the result will be the same as the
linear convolution of the original 2- and 3-point sequences. The following steps are involved in
computing x(n)*y(n):

1. Augment the sequences x(.) and y(.) by zero-padding: x
a
(n) = {1, 2, 0, 0} and
y
a
(n) = {2, 2, 1, 0}
2. Find X
a
(k) = DFT
4
{x
a
(n)} and Y
a
(k) = DFT
4
{y
a
(n)}.
3. Compute the product X
a
(k) Y
a
(k)
4. Compute x(n)*y(n) = x
a
(n)
4
y
a
(n) = IDFT{X
a
(k) Y
a
(k)}

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 35 of 53 Dr. Ravi Billa
Convolution Overlap-and-add The response, y(n), of a LTI system, h(n), can be obtained by
linear convolution

y(n) = ) ( ) ( n x n h -

Let the impulse response {h(n), n = 0 to M1} be of finite length M. The input sequence {x(n), n
= 0 to S1} is long but of finite length S. Recall that

Length {y(n)} = Length {h(n)}+ Length {x(n)} 1 = M + S 1,

Further, let h(n) be defined to be zero everywhere except over the interval [N
1
, N
2
]. Similarly, let
x(n) be defined to be non-zero over [N
3
, N
4
]. Then y(n) is non-zero over [(N
1
+ N
3
), (N
2
+ N
4
)].







One way to perform the convolution in pseudo real time (i.e., real time with a finite
delay) is by sectionalizing the input. We divide x(n) into K sections of length M each, where K
=
(
M S :

x
1
(n) = x(n), 0 n M 1
0, elsewhere


x
i
(n) = x(n), (i1)M n iM 1
0, elsewhere


x
K
(n) = x(n), (K1)M n KM 1
0, elsewhere

In the K
th
section (the last section) zeros may have to be appended. If, for instance, x(n) = {3, 1,
0, 1, 3, 2, 0, 1, 2, 1} with S = 10 and h(n) = {1, 1, 1} with M = 3, we have K =
(
3 10 = 4, with
the 4
th
section containing two appended zeros, and the sections are

x
1
(n) = {3, 1, 0}
x
2
(n) = {1, 3, 2}
x
3
(n) = {0, 1, 2}
x
4
(n) = {1,0, 0}

In general, then, x(n) can be written as the sum of all the sections
x(n) =

=
K
i
i
n x
1
) (
and the output y(n) becomes
y(n) = ) ( ) ( n x n h - =
)
`

-

=
K
i
i
n x n h
1
) ( ) (
y(n) = ) ( ) ( n x n h -
x(n)

h(n)
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 36 of 53 Dr. Ravi Billa
Using the linearity property this becomes
y(n) = { }

=
-
K
i
i
n h n x
1
) ( ) ( =

=
K
i
i
n y
1
) (
where ) (n y
i
= ) ( ) ( n h n x
i
- are the output sections. Let us examine y
1
(n) and y
2
(n). For i = 1 we
have

) ( ) ( ) (
1 1
n h n x n y - =

Since x
1
(n) and h(n) are of lengths M each and they are defined to be non-zero over [0, M1] and
[0, M1] respectively, the result y
1
(n) will be non-zero over [0, 2M2] and of length (2M1).
Similarly, for i = 2, x
2
(n) is defined over [M, 2M1] while h(n) remains unchanged. The resulting
) (
2
n y then is non-zero from (0+M) to (M1 + 2M1), i.e., over [M, 3M2] with a length of (2M
1). Comparing ) (
1
n y and ) (
2
n y it is seen that they overlap in the interval M n (2M2), over a
range of (2M2) M +1 = M1 points. Consequently the two must be added in this range (see
figure). This amounts to adding (M1) pairs of data.

















In a similar fashion x
3
(n) is defined over 2M n (3M1), so that ) (
3
n y is non-zero over
[2M, (4M2)]. Comparing ) (
2
n y and ) (
3
n y it is seen that they overlap in the interval 2M n
(3M2), consequently the two must be added in this range. This amounts to adding ((3M2)
2M +1) or (M1) pairs of data.









The overlap interval of ) (
1
n y and ) (
2
n y is disjoint from that of ) (
2
n y and ) (
3
n y . In
general, the overlap intervals of successive pairs of ) (n y
i
are mutually exclusive. Thus we
calculate successive ) (n y
i
for i = 0 to K and add each successive ) (n y
i
to the previous ) (n y
i
in
Overlap (Add)
(M1) points
y
2
(n): (2M 1) points
M 3M2 2M 2
y
1
(n): (2M 1) points
0 2M2 M
Overlap of
y
2
and y
3

(M1) points
Overlap of
y
3
and y
4

(M1) points
Overlap of
y
1
and y
2

(M1) points
0 M M1 2M 2M2 3M 3M2 n
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 37 of 53 Dr. Ravi Billa
the overlap region. Hence the procedure is called the overlap-and-add method. Each convolution
could be obtained by using the DFT of size (2M1) or greater so that the resulting circular
convolution would be a linear convolution. In principle rather than using the DFT we could zero-
pad h(n) and each of the ) (n x
i
s to a length of (2M1) and perform circular convolution to
generate the ) (n y
i
s which are then overlapped and added.

Input divided into sections of length L In the above development we divided x(n) into K sections
of length M each, where K =
(
M S . This need not be the case. We could divide x(n) into (some
number of) sections of length L each. The situation now looks as below and the overlap occurs
over a range of (M1) points the same as before.

















Once again each new section ) (n x
i
and h(n) are zero-padded to a length of (L+M 1) and circular
convolution performed to generate the new ) (n y
i
s which are overlapped and added to generate
y(n).

Note A little reflection shows that the input sequence x(n) need not be of finite length. As the
stream of input samples arrives we could sectionalize it into blocks of size L and proceed as
discussed above to generate the stream of blocks of y(n) as a continuous process.

Example 2.5.7 [Ramesh Babus Example 3.14] Find the output y(n) of a filter with impulse
response h(n) = {1, 1, 1} and input x(n) = {3, 1, 0, 1, 3, 2, 0, 1, 2, 1}.

Symmetry properties of the DFT Notation: R
N
(n) = 1 in [0, N1], and 0 elsewhere. Thus
x((n+m))
N
R
N
(n) means the circularly shifted version of the finite length sequence x(n) defined
over [0, N1]. Sometimes the R
N
(n) is omitted.
The following properties should be noted.

Sequence DFT Sequence DFT
1 x((n+m))
N
R
N
(n)
m k
N
W

X(k)
4 Re [x(n)] X
ep
(k)
2 x*(n) X*((k))
N
R
N
(k) 5 j Im [x(n)] X
op
(k)
3 x*((n))
N
R
N
(n) X*(k)

2L+M2
y
2
(n): (L+M 1) points
L L+M 2
Overlap (Add)
(M1) points
y
1
(n): (L+M 1) points
0 L+M2 L
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 38 of 53 Dr. Ravi Billa
Example 2.5.8 Show that DFT{x((n+m))
N
} =
m k
N
W

X(k).
Solution By definition
DFT {x((n+m))
N
} =

=
+
1
0
)) ((
N
n
n k
N N
W m n x
Set n+m = so that n = m and the limits n = 0 to N1 become = m to N1+m. Then the RHS
becomes
=

+
=

m N
m
km
N
k
N N
W W x
1
)) ((


The limits on will be changed to 0 to N1 resulting in
=

1
0
)) ((
N
km
N
k
N N
W W x

=
m k
N
W

X(k)

Based on the properties above, we can show that for a real sequence the following
symmetry properties of the DFT hold:

1. Re [X(k)] = Re [X((k))
N
] R
N
(k) 3. |X(k)| = |X((k))
N
| R
N
(k)
2. Im [X(k)] = Im [X((k))
N
] R
N
(k)

4. arg [X(k)] = arg [X((k))
N
] R
N
(k)

Example 2.5.9 [2009] Given that the real-valued sequence x(n) defined over 0 n N1 has the
DFT X(k) = ) (k X
R
+ ) (k jX
I
, 0 s k s N1 show that ) (k X
R
is an even function and ) (k X
I
is an
odd function of k.
Solution By definition we have
X(k) =

1
0
/ 2
) (
N
n
N n k j
e n x
t
, 0 s k s N1
= { }

=

1
0
) / 2 sin( ) / 2 cos( ) (
N
n
N kn j N kn n x t t , 0 s k s N1
=

=
1
0
) / 2 cos( ) (
N
n
N kn n x t j

=
1
0
) / 2 sin( ) (
N
n
N kn n x t , 0 s k s N1
With

=
=
1
0
) / 2 cos( ) ( ) (
N
n
R
N kn n x k X t and

=
=
1
0
) / 2 sin( ) ( ) (
N
n
I
N kn n x k X t the above DFT may be
written
X(k) = ) (k X
R
+ ) (k jX
I
, 0 s k s N1

Since ) / 2 cos( N kn t is an even function of k, that is, ) / ) ( 2 cos( N n k t = ) / 2 cos( N kn t for all k, it
follows that ) (k X
R
is an even function of k, that is, ) ( k X
R
= ) (k X
R
for all k.
Similarly, since ) / 2 sin( N kn t is an odd function of k, it follows that ) (k X
I
is an odd
function of k.
Do the above results depend on whether x(n) is real-valued or not?


2.6 Filtering through DFT/FFT

Filtering of a sequence x(n) may be done in the discrete time domain using the difference
equation. Alternatively, we may work in the frequency domain: Given x(n) we first find its DFT,
X(k) and then set selected components of X(k) = 0 (this is done so as to preserve the symmetry
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 39 of 53 Dr. Ravi Billa
properties of X(k) about the mid point of the sequence k = N/2). The resulting DFT is denoted
X
f
(k). We then find the IDFT of X
f
(k) which we shall denote as x
f
(n), which should be a filtered
version of x(n). Thus x(n) has been filtered entirely in the discrete frequency domain.
We illustrate with a signal consisting of two frequency components, a 2 Hz and a 4 Hz.
Given the signals x
1
(t) = cos 22t and x
2
(t) = cos 24t, the signal x(t) = x
1
(t) + x
2
(t) is sampled at
16 Hz. We construct below the discrete-time sequence x(n) and find its 8-point DFT, i.e., the
X(k) values. We then filter the signal in the frequency domain, i.e., work on the DFT values
instead of on the x(n) values and denote the filtered DFT values by X
f
(k). We then take the
IDFT of X
f
(k) resulting in the sequence x
f
(n).

x(t) = cos 22t + cos 24t
x(nT) = x(n) = cos 22nT + cos 24nT = cos 22n(1/16) + cos 24n(1/16)
= cos (n/4) + cos (n/2)
The cos 22t component has an analog frequency of 2 Hz. When sampled at 16 Hz its digital
frequency is 1/8 cycles/sample. Similarly, the 4 Hz component, cos 24t, sampled at 16 sps, has
a digital frequency of 1/4 cycles/sample.

Example 2.6.1 (a) Find the frequency and period of (i) x
1
(n) = cos (n/4) and (ii) x
2
(n) = cos
(n/2). Sketch the sequences x
1
(n), x
2
(n), and x(n) = x
1
(n) + x
2
(n) for 0 s n s 7.
Solution Arrange cos (n/4) in the format cos (2 f n). Thus, cos (n/4) = cos (2(1/8)n), from
which the digital frequency is identified as f = 1/8 cycle/sample or e = /4 rad/sample. The
sequence values are:
x
1
(n) =

2
1
, 1 , 0,
2
1
, 1,
2
1
, 0,
)
`

2
1

x
2
(n) = {1, 0, 1, 0, 1, 0, 1, 0}
x(n) = x
1
(n) + x
2
(n) =

2
1
, 2 , 1,
2
1
, 0,
2
1
, 1,
)
`

2
1


www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 40 of 53 Dr. Ravi Billa
The sequences x
1
(n), x
2
(n) and x(n) are sketched below.








































2 / 1
n
8 7 1
2
2 / 1
1
x(n) = x
1
(n) + x
2
(n)
1
1
x
2
(n) = cos (n/2)
n
8 7 1
1
2 / 1
x
1
(n) = cos (n/4)
n
8 7 1
1
2 / 1
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 41 of 53 Dr. Ravi Billa
In MATLAB the following segment plots the three functions x
1
(t), x
2
(t) and x(t).

t = 0:1/160:0.5; x1t = cos(2*pi*2*t); x2t = cos(2*pi*4*t);
xt = x1t + x2t;
%
subplot(3,1,1), plot(t,x1t); xlabel('t'), ylabel('x1(t)');
title('x1(t) = cos 2\pi2t');
%
subplot(3,1,2), plot(t,x2t); xlabel('t'), ylabel('x2(t)');
title('x2(t) = cos 2\pi4t');
%
subplot(3,1,3), plot(t,xt); xlabel('t'), ylabel('x(t)');
title('x(t) = cos 2\pi2t + cos 2\pi4t');


0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
-1
0
1
t
x
1
(
t
)
x1(t) = cos 2t2t
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
-1
0
1
t
x
2
(
t
)
x2(t) = cos 2t4t
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
-2
0
2
t
x
(
t
)
x(t) = cos 2t2t + cos 2t4t



In MATLAB the following segment plots the two functions x
1
(n), x
2
(n) and x(n).

%t = 0:1/160:0.5; x1t = cos(2*pi*2*t); x2t = cos(2*pi*4*t);
%xt = x1t + x2t;
%
n = 0:8; x1n = cos(pi*n/4); x2n = cos(pi*n/2);
xn = x1n + x2n,
%
subplot(3,1,1), stem(n,x1n); xlabel('n'), ylabel('x1(n)');
title('x1(n) = cos(\pi n/4)');
%
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 42 of 53 Dr. Ravi Billa
subplot(3,1,2), stem(n,x2n); xlabel('n'), ylabel('x2(n)');
title('x2(n) = cos(\pi n/2)');
%
subplot(3,1,3), stem(n,xn); xlabel('n'), ylabel('x(n)');
title('x(n) = cos(\pi n/4)+ cos(\pi n/2)');

The sequence is x(n) = {2, 0.707, -1, -0.707, 0, -0.707, -1, 0.707}

0 1 2 3 4 5 6 7 8
-1
0
1
n
x
1
(
n
)
x1(n) = cos(t n/4)
0 1 2 3 4 5 6 7 8
-1
0
1
n
x
2
(
n
)
x2(n) = cos(t n/2)
0 1 2 3 4 5 6 7 8
-2
0
2
n
x
(
n
)
x(n) = cos(t n/4)+ cos(t n/2)


Example 2.6.1 (b) Find the 8-point DFT (8-point FFT using either DIT or DIF, or use the direct
calculation) of x
1
(n) = cos (n/4), for 0 s n s 7. Sketch the sequence X
1
(k).
In MATLAB the following segment plots the magnitude and phase angle of X
1
(k):

n = 0:7; x1n = cos(pi*n/4), X1k = fft(x1n),
%
% MX1k = magnitude of X1k, AX1k = phase angle of X1k
MX1k = abs(X1k); AX1k = angle(X1k);
%
subplot(2,1,1), stem(n, abs(X1k)); xlabel('k'), ylabel('|X1(k)|');
title ('Magnitude of X1(k)');
%
subplot(2,1,2), stem(n, angle(X1k)); xlabel('k'), ylabel('<X1(k)');
title ('Phase of X1(k)');

The sequence and DFT values are:

x
1
(n) = {1 0.707 0 -0.707 -1 -0.707 -0 0.707}
X
1
(k) = {-0 (4 - 0i) 0 (-0 - 0i) 0 (-0 + 0i) 0 (4 + 0i)}
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 43 of 53 Dr. Ravi Billa
) (
1
k X = {0 4 0 0 0 0 0 4}
) (
1
k X Z = {3.1416 -0.0000 0 -2.9873 0 2.9873 0 0.0000}

!!! Note that all phase angle values should be zeros, that is, ) (
1
k X Z = 0 for all k.

The MATLAB plots for magnitude and phase angle are shown below. The 2 Hz component is
indicated by X
1
(1) = 4 (and, from symmetry considerations, X
1
(7) = 4).
With regard to the phase angle, strictly speaking, the phase of X
1
(k) = 0 for all k since
X
1
(k) is real valued for all k. Check out why!!!: When the input is listed explicitly as

x1n = [1, 1/sqrt(2), 0, -1/sqrt(2), -1, -1/sqrt(2), 0, 1/sqrt(2)]

the program gives the correct phase angle calculations, but not when it is specified implicitly as

n = 0:7; x1n = cos(pi*n/4)

0 1 2 3 4 5 6 7
0
1
2
3
4
k
|
X
1
(
k
)
|
Magnitude of X1(k)
0 1 2 3 4 5 6 7
-4
-2
0
2
4
k
<
X
1
(
k
)
Phase of X1(k)


Example 2.6.1 (c) Find the 8-point DFT of x(n) = cos (n/4) + cos (n/2), for 0 s n s 7. Sketch
the sequence X(k).
Solution Consider the 8-point sequence x(n) for n = 0 to 7 obtained by sampling x(t) at 16 Hz.
The length of the sequence is N = 8. The sequence values are
x(n) =

2
1
, 2 , 1,
2
1
, 0,
2
1
, 1,
)
`

2
1

The corresponding DFT is given by
X(k) =

1
0
/ 2
) (
N
n
N n k j
e n x
t
, k = 0 to (N1)
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 44 of 53 Dr. Ravi Billa
and may be obtained using either the DIT or the DIF form of FFT:

X(k) = {0, 4, 4, 0, 0, 0, 4, 4}

|
k=0


The DFT is sketched below: there is a component at 2 Hz. (k = 1) and another at 4 Hz. (k = 2) as
would be expected.

















Note that the DFT sequence shows a component at 2 Hz and another at 4 Hz, corresponding to k
= 1 and 2 respectively.
In MATLAB the following segment plots the magnitude and phase angle of X(k). Note
that x(n) is specified by an explicit list.

%n = 0:7; xn = cos(pi*n/4) + cos(pi*n/2),
xn = [2, 1/sqrt(2), -1, -1/sqrt(2), 0, -1/sqrt(2), -1, 1/sqrt(2)], Xk = fft(xn),
%
% MXk = magnitude of Xk, AXk = phase angle of Xk
MXk = abs(Xk), AXk = angle(Xk),
%
k = 0:7;
subplot(2,1,1), stem(k, abs(Xk)); xlabel('k'), ylabel('|X(k)|');
title ('Magnitude of X(k)');
%
subplot(2,1,2), stem(k, angle(Xk)); xlabel('k'), ylabel('<X(k)');
title ('Phase of X(k)');

The sequence and DFT values are:

x(n) = {2, 0.707, -1, -0.707, 0, -0.707, -1, 0.707}
X(k) = {0 4 4 0 0 0 4 4}
) (k X = {0 4 4 0 0 0 4 4}
) (k X Z = {0 0 0 0 0 0 0 0}

0 1 2 3 4 5 6 7 3 2 1
X(k)
k
8
F
s
= 16 Hz
4
Line of Symmetry
F
0
= 2 Hz
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 45 of 53 Dr. Ravi Billa
The MATLAB plots for magnitude and phase angle are shown below. The 2 Hz component is
indicated by X(1) = 4 (and, from symmetry considerations, X(7) = 4). Similarly, the 4 Hz
component is indicated by X(2) = X(6) = 4.
0 1 2 3 4 5 6 7
0
1
2
3
4
k
|
X
(
k
)
|
Magnitude of X(k)
0 1 2 3 4 5 6 7
-1
-0.5
0
0.5
1
k
<
X
(
k
)
Phase of X(k)



Example 2.6.1 (d) [Filtering] Next we would like to filter the sequence x(n) = cos (n/4) + cos
(n/2) so that the 4 Hz component is removed.

Solution In terms of the DFT sequence X(k) this means setting X(2) and X(6) to zero. In order to
preserve the symmetry properties of the DFT we should set both X(2) and X(6) = 0, not just X(2).
The resulting DFT sequence is denoted X
f
(k) and is given by

X
f
(k) = {0, 4, 0, 0, 0, 0, 0, 4}

|
k=0


We next find the inverse DFT of the above X
f
(k) by using either the DIT or the DIF form of the
FFT. The result is denoted by x
f
(n). Using the IDFT formula we have
x
f
(n) =
N
1
( )

=
1
0
/ 2
N
k
N n k j
f
e k X
t
, n = 0, 1, , N1
=
8
1
( )

=
7
0
8 / 2
k
n k j
f
e k X
t
, n = 0 to 7

It will be seen that x
f
(n) is equal to the original x
1
(n) component (= cos n/4, from the 2 Hz.
component; see plot of x
1
(n) earlier); that is
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 46 of 53 Dr. Ravi Billa
x
f
(n) = x
1
(n) =

2
1
, 1 , 0,
2
1
1,
2
1
, 0,
)
`

2
1

This is low pass filtering where we have selectively removed the 4 Hz component.
In MATLAB the following segment finds the inverse DFT, x
f
(n), from the given X
f
(k).

Xfk = [0, 4, 0, 0, 0, 0, 0, 4],
n = 0:7; xfn = ifft(Xfk),
stem(n, xfn); xlabel('n'), ylabel('xf(n)');
title ('Filtered signal xf(n)');

The filtered version is x
f
(n) = {1 0.707 0 -0.707 -1 -0.707 0 0.707}
0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
n
x
f
(
n
)
Filtered signal xf(n)



To remove all frequency components above 2 Hz (in this example the 4, 6 and 8 Hz
components), we set X(2) = X(6) = 0 for the 4 Hz, X(3) = X(5) = 0 for the 6 Hz, and X(4) = 0 for
the 8 Hz, once again preserving symmetry. In this example, of course, there are no 6 or 8 Hz
components.
Similarly high pass filtering is done by deleting X(1) and X(7) set them to zero
preserving symmetry once again. In this case X
fHP
(k) = {0, 0, 4, 0, 0, 0, 4, 0}.


2.7 Picket-fence effect

Example 2.7.1 The signal x(t) = cos 22t is sampled at 16 Hz.
(a) What frequency components do you expect to see in its DFT?
(b) Take 8 samples and calculate the 8-point DFT.
Solution (b) Using x(n) = cos 22n(1/16) = cos (n/4), the sequence values are
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 47 of 53 Dr. Ravi Billa

x(n) = {1, 1/sqrt(2), 0, -1/sqrt(2), -1, -1/sqrt(2), 0, 1/sqrt(2)}

Note that the average value of the sequence (the dc component) is zero. The MATLAB program
follows:

xn = [1, 1/sqrt(2), 0, -1/sqrt(2), -1, -1/sqrt(2), 0, 1/sqrt(2)]; Xk = fft(xn),
%
% MXk = magnitude of Xk, AXk = phase angle of Xk
MXk = abs(Xk); AXk = angle(Xk);
%
k = 0:7;
subplot(2,1,1), stem(k, abs(Xk)); xlabel('k'), ylabel('|X(k)|');
title ('Magnitude of X(k)');
%
subplot(2,1,2), stem(k, angle(Xk)); xlabel('k'), ylabel('<X(k)');
title ('Phase of X(k)');

The DFT values are:

X(k) = {0 4 0 0 0 0 0 4}
) (k X = {0 4 0 0 0 0 0 4}
) (k X Z = {0 0 0 0 0 0 0 0}

The frequency resolution is F
s
/N = 16/8 = 2 Hz. The table below shows that the 8-point
DFT contains a component at 2 Hz, corresponding to k = 1. The DFT values are all real numbers
symmetrically disposed about k = 4, the center of symmetry.

k=0


X(k) = {0, 4, 0, 0, 0, 0, 0, 4}
Hz 0 2 4 6 8
(F
s
/2)
10 12 14

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 48 of 53 Dr. Ravi Billa
0 1 2 3 4 5 6 7
0
1
2
3
4
k
|
X
(
k
)
|
Magnitude of X(k)
0 1 2 3 4 5 6 7
-1
-0.5
0
0.5
1
k
<
X
(
k
)
Phase of X(k)


Example 2.7.2 [Zero-padding] The first 8 sample values of a 2-Hz cosine, x(t) = cos 22t,
obtained at a sampling rate of 16 samples/second are given below:

x(n) = {1, 1/sqrt(2), 0, -1/sqrt(2), -1, -1/sqrt(2), 0, 1/sqrt(2)}

Find the 16-point DFT using zero padding.
Solution The zero-padded sequence is given by

x(n) = {1, 1/sqrt(2), 0, -1/sqrt(2), -1, -1/sqrt(2), 0, 1/sqrt(2), 0, 0, 0, 0, 0, 0, 0, 0}

Note that when zero padded the average value of the sequence is no longer zero. The frequency
resolution of the DFT is
Frequency resolution =
s po of Number
Frequency Sampling
int
=
N
F
s
=
16
16 Hz
= 1 Hz.
The 2 Hz component corresponds to X(k) with k = 2.

In MATLAB:

xn = [1, 1/sqrt(2), 0, -1/sqrt(2), -1, -1/sqrt(2), 0, 1/sqrt(2)],
Xk = fft(xn, 16), %x(n) is zero-padded to a length of 16
%
% MXk = magnitude of Xk, AXk = phase angle of Xk
MXk = abs(Xk), AXk = angle(Xk),
%
k = 0:15;
subplot(3,1,1), stem(k, abs(Xk)); xlabel('k'), ylabel('|X(k)|');
title ('Magnitude of X(k)');
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 49 of 53 Dr. Ravi Billa
%
subplot(3,1,2), stem(k, angle(Xk)); xlabel('k'), ylabel('<X(k)');
title ('Phase of X(k)');
%
xn16 = ifft(Xk),
n = 0:15;
subplot(3,1,3), stem(n, xn16); xlabel('n'), ylabel('x(n)');
title ('Zero-padded sequence xn16');

The DFT (reproduced from the MATLAB output) is

X(k) = {0, (1+1.7654i), 4, (1-2.8478i), 0, (1-0.8478i), 0, (1-0.2346i),
0, {1+0.2346i), 0, (1+0.8478i), 0, (1+2.8478i), 4, (1-1.7654i)}
0 5 10 15
0
2
4
k
|
X
(
k
)
|
Magnitude of X(k)
0 5 10 15
-2
0
2
k
<
X
(
k
)
Phase of X(k)
0 5 10 15
-1
0
1
n
x
(
n
)
Zero-padded sequence xn16


Example 2.7.3 [Without zero-padding] Given all 16 sample values of a 2-Hz cosine, x(t) = cos
22t, obtained at a sampling rate of 16 samples/second find its 16-point DFT.
Solution The frequency resolution of the DFT is
Frequency resolution =
s po of Number
Frequency Sampling
int
=
N
F
s
=
16
16 Hz
= 1 Hz.
The 2 Hz component corresponds to X(k) with k = 2.

t = 0: 1/16: 15/16; xn = cos (2*pi*2*t), Xk = fft(xn),
%
% MXk = magnitude of Xk, AXk = phase angle of Xk
MXk = abs(Xk), AXk = angle(Xk),
%
k = 0:15;
subplot(3,1,1), stem(k, abs(Xk)); xlabel('k'), ylabel('|X(k)|');
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 50 of 53 Dr. Ravi Billa
title ('Magnitude of X(k)');
%
subplot(3,1,2), stem(k, angle(Xk)); xlabel('k'), ylabel('<X(k)');
title ('Phase of X(k)');
%
n = 0:15;
subplot(3,1,3), stem(n, xn); xlabel('n'), ylabel('x(n)');
title ('Sequence x(n)');

The DFT (reproduced from the MATLAB output) is

X(k) = {0, (-0+0i), (8-0i), (0-0i), (0-0i), (0-0i), (0-0i), (0+0i),
-0, (0-0i), (0+0i), (0+0i), (0+0i), (0+0i), (8+0i), (-0-0i)}
0 5 10 15
0
5
10
k
|
X
(
k
)
|
Magnitude of X(k)
0 5 10 15
-5
0
5
k
<
X
(
k
)
Phase of X(k)
0 5 10 15
-1
0
1
n
x
(
n
)
Sequence x(n)

Specifying the sequence values explicitly as below produces correct phase values (rather
than implicitly by n = 0: 1 : 15; x = cos (pi*n/4), X = fft(x))

%Listing the sequence values explicitly
xn1 = [1, 1/sqrt(2), 0, -1/sqrt(2), -1, -1/sqrt(2), 0, 1/sqrt(2)],
xn2 = [1, 1/sqrt(2), 0, -1/sqrt(2), -1, -1/sqrt(2), 0, 1/sqrt(2)],
xn = [xn1,xn2], Xk = fft(xn),
%
% MXk = magnitude of Xk, AXk = phase angle of Xk
MXk = abs(Xk), AXk = angle(Xk),
%
k = 0:15
subplot(3,1,1), stem(k, abs(Xk)); xlabel('k'), ylabel('|X(k)|');
title ('Magnitude of X(k)');
%
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 51 of 53 Dr. Ravi Billa
subplot(3,1,2), stem(k, angle(Xk)); xlabel('k'), ylabel('<X(k)');
title ('Phase of X(k)');
%
n = 0:15;
subplot(3,1,3), stem(n, xn); xlabel('n'), ylabel('x(n)');
title ('16-point sequence xn');

0 5 10 15
0
5
10
k
|
X
(
k
)
|
Magnitude of X(k)
0 5 10 15
-1
0
1
k
<
X
(
k
)
Phase of X(k)
0 5 10 15
-1
0
1
n
x
(
n
)
16-point sequence xn


The 16-point DFT is X(k) = {0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0}. The DFT contains a
component at 2 Hz. The DFT values are all real numbers symmetrically disposed about k = 8, the
center of symmetry.

k 0 2 8 15
X(k) {0 0 8 0 0 0 0 0 0 0 0 0 0 0 8 0}
Hz 2 8


Example 2.7.4 The signal x(t) = cos 22t is sampled at 12 Hz (still satisfies the sampling
theorem). Calculate (1) the 6-point DFT and (2) the 8-point DFT. Compare the results.
Solution The resulting sequence is x(n) = cos 22n(1/12) = cos (n/3).
(1) 6-point DFT.

n = 0: 1 : 5; x = cos (pi*n/3), X = fft(x)

The samples are
x(n) =

2
1
, 1 ,
2
1
, 1,
2
1
,
)
`

2
1

www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 52 of 53 Dr. Ravi Billa
The average value of the sequence (the dc component) is zero. The frequency resolution is F
s
/N
= 12/6 = 2 Hz. The DFT is

X(k) = {0, 3, 0, 0, 0, 3}

which does show a component at 2 Hz.

(2) 8-point DFT.

n = 0: 1 : 7; x = cos (pi*n/3), X = fft(x)

The samples are
x(n) =

2
1
, 1 ,
2
1
, 1,
2
1
,
2
1
, 1,
)
`

2
1

Note that the average value of the sequence (the dc component) is not zero. The frequency
resolution is F
s
/N = 12/8 = 1.5 Hz. The DFT is

X(k) = {1.5, (2.5607 + j2.5607), -j1.5, (0.4393 - j0.4393),
0.5, (0.4393 + j0.4393), j1.5, (2.5607 - j2.5607)}

It is not possible to know that there is a component at 2 Hz.

Example 2.7.5 For the signal x(t) = cos 22t + cos 24t choose a sampling frequency of 12Hz
(still satisfies sampling theorem). Find the N-point DFT for (a) N = 6, (b) N = 8, and (c) N = 12.

(a) For N = 6

x(n) = cos (22n/12) + cos (24n/12) = cos (n/3) + cos (2n/3)

n = 0: 1 : 5; x = cos (pi*n/3) + cos (2*pi*n/3), X = fft(x)

The samples are

x(n) = {2, 0, -1, 0, -1, 0}

The dc component is zero. The frequency resolution is F
s
/N = 12/6 = 2 Hz. The DFT is

X(k) = {0, 3, 3, 0, 3, 3}

Both the 2 Hz and the 4 Hz components show up.

k 0 3 5
X(k) {0 3 3 0 3 3
Hz 0 2 4 6 8 10

(b) For N = 8

x(n) = cos (22n/12) + cos (24n/12) = cos (n/3) + cos (2n/3)

n = 0: 1 : 7; x = cos (pi*n/3) + cos (2*pi*n/3), X = fft(x)
www.jntuworld.com
www.jntuworld.com
DSP-2 (DFS & DFT) 53 of 53 Dr. Ravi Billa

The samples are

x(n) = {2, 0, 1, 0, 1, 0, 2, 0}

This particular set has a nonzero dc component. The frequency resolution is F
s
/N = 12/8 = 1.5
Hz. The DFT is

X(k) = {2, (3 + j3), 0, (3 - j3), 2, (3 + j3), 0, (3 - j3)}

Neither the 2 Hz nor the 4 Hz component can show up.

k 0 4 7
X(k) {2 3+j3 0 3j3 2 3+j3 0 3j3
Hz 0 1.5 3 4.5 6 7.5 9 10.5











Example 2.7.6 For the signal x(t) = cos 22t + cos 23t + cos 24t choose a sampling frequency
of 12Hz (still satisfies sampling theorem). Find the N-point DFT for (a) N = 6, (b) N = 8.

(a) For N = 6

x(n) = cos (22n/12) + cos (23n/12) + cos (24n/12)
= cos (n/3) + cos (n/2) + cos (2n/3)

n = 0: 1 : 5; x = cos (pi*n/3) + cos (n/2) + cos (2*pi*n/3), X = fft(x)

The samples are

x(n) = {3, 0, -2, 0, 0, 0}

The dc component is not zero. The frequency resolution is F
s
/N = 12/6 = 2 Hz. The DFT is

X(k) = {1, (4 + j1.732), (4 - j1.732), 1, (4 + j1.732), (4 - j1.732)}

Both the 2 Hz and the 4 Hz components show up, but the 3 Hz component is missing.

k 0 3 5
X(k) {1 4 + j1.732 4 - j1.732 1 4 + j1.732 4 - j1.732
Hz 0 2 4 6 8 10


X(k)
k
8 1 0
1.5 Hz 3 Hz
12 Hz
2 Hz 4 Hz
2
www.jntuworld.com
www.jntuworld.com

You might also like