Nov '05CS3291 : Section 81 UNIVERSITY of MANCHESTER Department
of Computer Science CS3291 Digital Signal Processing 05 Section 8
Introduction to the DFT
Slide 2
Nov '05CS3291 : Section 82 DTFT of {x[n]} is: If {x[n]}
obtained from x a (t), correctly bandlimited then: for - < <
: = T DTFT is convenient way of calculating X a (j ) by
computer.
Slide 3
Nov '05CS3291 : Section 83 Two difficulties: (i)Infinite range
of summation (ii) X(e j ) is continuous function of Solutions: (i)
Time-domain windowing: Restrict {x[n]} to { x[0], x[1], x[N-1]}
{x[n]} 0, N-1 (ii) Frequency-domain sampling: Store values of X(e j
) for - < < For real signals we only need 0 < but
generalise to complex signals Instead of - < < take 0 <
2
Slide 4
Nov '05CS3291 : Section 84 Why take 0 < 2 ? X(e j ) = X( e j
( + 2 ) ) for any So for X(e - j / 3 ) look up X(e j 5 / 3 ). Same
information, & it is convenient for to start off at 0. In many
cases, not interested in >
Slide 5
Nov '05CS3291 : Section 85 Taking M equally spaced samples over
0 < 2 we get : { X[k] } 0, M-1 { X[0], X[1],, X[M-1] } where
X[k] = X(exp(j k )) with k = 2 k/M
Slide 6
Nov '05CS3291 : Section 86 For spectral analysis, the larger M,
the better for drawing accurate graphs etc. But, if we need minimum
M for storage of unambiguous spectrum, take M=N. DFT: {x[n]} 0, N-1
{X[k]} 0, N-1 (complex) (complex) k = 2 k/N
Slide 7
Nov '05CS3291 : Section 87 DFT transforms a finite sequence to
another finite sequence. DTFT transforms infinite sequence to
continuous functn of Inverse DFT: {X[k]} 0, N-1 {x[n]} 0, N-1 Note
Similarity with DFT:
Slide 8
Nov '05CS3291 : Section 88 Programming the DFT & its
inverse: k = 2 k/N Similarity exploited by programs able to perform
DFT or its inverse using same code. Programs to implement these
equations in a direct manner given in MATLAB (using complex arith)
& C (using real arith only). These direct programs are very
slow & FFT is much faster.
Slide 9
Nov '05CS3291 : Section 89 % Given N complex time-domain
samples in array x[1:N] E = 2*pi/N ; for k=0 : N-1 X(1+k) = 0 + j*0
; Wk =k*E ; for L = 0 : N-1 C = cos(L*Wk) + j *sin(L*Wk); X(1+k) =
X(1+k) + x(1+L) * C; end; % Now have N complex freq-dom samples in
array X[1:N] Direct DFT using complex arithmetic in MATLAB
Slide 10
Nov '05CS3291 : Section 810 % Given N complex freq-domain
samples in array x[1:N] E = -2*pi/N ; for k=0 : N-1 X(1+k) = 0 +
j*0 ; Wk =k*E ; for L = 0 : N-1 C = cos(L*Wk) + j *sin(L*Wk);
X(1+k) = X(1+k) + x(1+L) * C; end; X(1+k) = X(1+k)/N ; end; % Now
have N complex time-dom samples in array X[1:N] Direct inverse DFT
using complex arithmetic in MATLAB
Slide 11
Nov '05CS3291 : Section 811 % Given N complex samples in array
x[1:N] if (Invers == 1) E = -2*pi/N else E = 2*pi/N ; for k=0 : N-1
X(1+k) = 0 + j*0 ; Wk =k*E ; for L = 0 : N-1 C = cos(L*Wk) + j
*sin(L*Wk); X(1+k) = X(1+k) + x(1+L) * C; end; if (Inverse == 1)
X(1+k) = X(1+k)/N ; end; % Now have N complex samples in array
X[1:N] Direct forward/inverse DFT using complex arith in
MATLAB
Slide 12
Nov '05CS3291 : Section 812 // Direct fwd/inverse DFT using
real arith only in C void directdft(void) // DFT or Inverse DFT by
direct method. { // Order=N, Real & imag parts of input in
arrays xr & xi // Output:- Real part in array X, Imag part in Y
// Invers is 0 for DFT, 1 for IDFT int k, L; float c,e,s,wk;
if(Invers==1) e = -2.0*PI/(float)N; else e = 2.0*PI/(float)N;
for(k=0;k