Digital Signal Processing Reference
In-Depth Information
changes (scaling and complex conjugate of
W
) to obtain an eight-point IFFT
(reverse) flow graph from an eight-point FFT (forward) flow graph. The resulting
flow graph becomes an IFFT flow graph similar to Figure 6.5. Verify that the result-
ing output sequence is
x
(0)
=
1,
x
(1)
=
1,...,
x
(7)
=
0, which represents the rectan-
gular input sequence in Exercise 6.1.
6.8 PROGRAMMING EXAMPLES
Example 6.1: DFT of a Sequence of Real Numbers with Output
from the CCS Window (
DFT
)
This example illustrates the DFT of an
N
-point sequence. Figure 6.12 shows a listing
of the program
DFT.c
, which implements the DFT. The input sequence is
x(n).
The program calculates
N
-
Â
1
()
=
(
{
()
nk
Xk
DFT
xn
=
xnW
k
=
01
, ,...,
N
-
1
n
=
0
e
-
j
2p/
N
are the twiddle constants. This can be decomposed into a sum of
real components and a sum of imaginary components, or
where
W
=
N
-
Â
1
{
()
}
=
()
(
)
Re
X k
x n
cos
2
p
nk N
n
=
0
N
-
Â
1
{
}
=
()
()
(
)
IM
X k
x n
sin 2
p
nk N
n
=
0
Using a sequence of real numbers with an integer number of cycles
m
,
X
(
k
)
=
0 for
all
k
, except at
k=m
and at
k
=
N
-
m
.
Build this project as
DFT
.
The input
x(n)
is a cosine with
N
=
8 data points. To
test the results, load the program. Then:
1.
Select View
Watch Window and insert the two expressions
j
and
out
(right
click on the Watch window). Click on
Æ
out
to expand and view out[0] and
out[1], which represent the real and imaginary components, respectively.
2.
Place a breakpoint at the bracket “}” that follows the DFT function call.
3.
Select Debug
+
Animate (Animation speed can be controlled through
Options
). Verify that the real component value
out[0]
is large (3996) at
j
=
Æ
1 and at
j
=
7, while small otherwise. Since
x(n)
is a one-cycle sequence,
m
=
8, a “spike” occurs at
j = m = 1
and at
j = N - m = 7
. The flowing two MATLAB commands can be
used to verify these results (see also Appendix D):
1. Since the number of points is
N
=
Search WWH ::
Custom Search