of 34

thegame4626
• Category

## Documents

• view

234

0

description

Introduction to DTFT and DFT

### Transcript of Dft Spectral Analysis

• Introduction to the Discrete-TimeFourier Transform and the DFT

C.S. Ramalingam

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 1 / 37

• The Discrete-Time Fourier Transform

The DTFT tells us what frequency components are present

X () =

n=x [n]ejn

|X ()| : magnitude spectrumX () : phase spectrum

E.g.: exp(j0n) has only one frequency component at = 0

exp(j0n) is an infinite duration complex sinusoid

X () = 2pi ( 0) [pi, pi)the spectrum is zero for 6= 0

cos(0n) and sin(0n) have frequency components at 0phase spectra for sin and cos are different

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 4 / 37

• The Discrete-Time Fourier Transform

The DTFT is periodic with period 2pi

X ( + 2pi) =

n=x [n]ej(+2pi)n

= X ()

X () is also commonly denoted by X (e j)

the notation X (e j) conveys the periodicity explicitly

X () over one period contains all the information

typically we consider either [0, 2pi) or [pi, pi)

DTFT of exp(j0n) over all :

X () =

k=2pi ( 0 + 2pik)

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 5 / 37

• Inverse DTFT

x [n] =1

2pi

pipi

X (e j) e jn d

Example:

1

2pi

pipi

2pi ( 0) e jn d = e j0n

If 0 = 0, then x [n] = 1 for all n, i.e., DC sequenceIts transform is an impulse located at = 0 with strength 2pi

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 6 / 37

• Convolution-Multiplication Property

Multiplication in one domain is equivalent to convolution inthe other domain

x [n] y [n] DTFT 12pi

X () Y ()

x [n] y [n] DTFT X () Y ()

x [n] y [n] =

k=x [k] y [n k]

X () Y () = pipi

X ()Y ( ) d

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 7 / 37

• Rectangular Window and its Transform

Rectangular window:

w [n] = 1 n = N, . . . , 0, . . .N

W () =sin(2N + 1)/2

sin/2

5 0 5Time

pi

1

4

2

0

2

4

6

8

10

12

Frequency

|X(ej )

|

pi0

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 8 / 37

• Some Observations

W (e j)=0

= 2N + 1

First zero crossing occurs when =2pi

2N + 1

Number of zero crossings = 2N

As N increases, main lobe height increases and widthdecreases

Transform of exp(j0n)w [n] has its mainlobe centred at 0

DTFT (x [n] w [n]) = 12pi

X () W ()= ( 0) W ()= W ( 0)

DTFT (cos(0n)w [n]) =1

2W ( 0) + 1

2W ( + 0)

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 9 / 37

• Windowed Sinusoid Example

2 0 2 4 6 8 10 12 14 16

1

0

1

Time (ms)

Gated sinusoid with f0 = 1 kHz

4000 3000 2000 1000 0 1000 2000 3000 40000

20

40

60

Frequency (Hz)

Mag

nitu

de

4000 3000 2000 1000 0 1000 2000 3000 400020

0

20

40

Frequency (Hz)

Log

Mag

nitu

de

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 10 / 37

• Single Real Sinusoid Frequency Estimation

f0 is estimated from peak location

In general, the peaks are not exactly at f0This is because of sidelobe interference

If f0 is closer to DC

sidelobe interference increases

shifts peak further away from true location

Interference is least when sinusoidal frequency is at fs/4

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 11 / 37

• Examples of Peak Shifting

0 100 200 300 400 5000

5

10

15

20

25

30

f0 = 100 HzPeak: 105 Hz

Frequency (Hz)

Mag

nitu

de (d

B)

800 900 1000 1100 120010

5

0

5

10

15

20

25

30

Frequency (Hz)

Mag

nitu

de (d

B)

f0 = 1 kHzPeak: 1.002 kHz

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 12 / 37

• Effect of Increased Data Length

Longer duration sinusoids spectrum is narrowerless sidelobe interference peak closer to true value

0 100 200 300 400 5000

5

10

15

20

25

30

f0 = 100 HzPeak: 105 HzT = 6.25 ms

Frequency (Hz)

Mag

nitu

de (d

B)

0 100 200 300 400 5000

5

10

15

20

25

30

35

Frequency (Hz)

Mag

nitu

de (d

B)

f0 = 100 HzPeak: 101 HzT = 12.5 ms

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 13 / 37

• Use of Data Windows

Useful for data containing sinusoids

Sidelobes of a stronger sinusoid will mask the main lobe of anearby weak sinusoid

We multiply x [n] by data window w [n] before computing theDTFT

if we merely truncate a signal, it is equivalent to applying arectangular window

Why consider non-rectangular windows?

sidelobes fall of faster

nearby weaker sinusoid becomes more visible

price paid: main lobe of each sinusoid broadens

two close peaks may merge into one

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 14 / 37

• Commonly Used Windows

Name w [k] Fourier transform

Rectangular 1 WR(f ) =sin pif (2N + 1)

sin pif

Bartlett 1 |k |N

1

N

(sin pifN

sin pif

)2Hanning 0.5 + 0.5 cos

pik

N0.25WR

(f 12N

)+ 0.5WR(f ) +

0.25WR(f + 12N

)Hamming 0.54 + 0.46 cos

pik

N0.23WR

(f 12N

)+ 0.54WR(f ) +

0.23WR(f + 12N

)w [k] = 0 for |k | > N

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 15 / 37

• Windowed Sinusoid

5 0 5 10 15 201

0.5

0

0.5

1Rectangular Window

5 0 5 10 15 201

0.5

0

0.5

1

Ampl

itude

Hamming Window

5 0 5 10 15 201

0.5

0

0.5

1

Time (ms)

Hanning Window

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 16 / 37

• Hamming Vs. Hanning

0.05 0.025 0 0.025 0.0560

40

20

0

Frequency

Mag

nitu

de (d

B)

0.5 0.25 0 0.25 0.5

100

50

0Fourier Transforms of Hamming and Hanning Windows

Frequency

Mag

nitu

de (d

B)

HammingHanning

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 17 / 37

• Example: How Many Sine Waves Are there?

0.1 0.12 0.14 0.16 0.18 0.2 0.2260

40

20

0

20

40

60

Frequency

Mag

nitu

de (d

B)Two Sinusoids, or More?

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 18 / 37

• Example: Three Sine Waves

0.1 0.12 0.14 0.16 0.18 0.2 0.2260

40

20

0

20

40

60

Frequency

Mag

nitu

de (d

B)Three Sinusoids: Rectangular Window

0.150.15 0.157

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 19 / 37

• Example: Three Sine Waves

0.1 0.12 0.14 0.16 0.18 0.2 0.2260

40

20

0

20

40

60

Frequency

Mag

nitu

de (d

B)Three Sinusoids: Hanning Window

0.150.15 0.157

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 20 / 37

• Three Sine Waves

0.1 0.12 0.14 0.16 0.18 0.2 0.2260

40

20

0

20

40

60

Frequency

Mag

nitu

de (d

B)Rectangular Vs. Hamming Vs. Hanning

0.150.15 0.157

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 21 / 37

• Three Sine Waves: Three Diffrent Data Lengths

0.1 0.12 0.14 0.16 0.18 0.2 0.224020

0204060

Duration T

0.1 0.12 0.14 0.16 0.18 0.2 0.224020

020406080

Duration 5T

0.1 0.12 0.14 0.16 0.18 0.2 0.22

0

50

100

Frequency

Duration 50T

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 22 / 37

• The Discrete Fourier Transform

Since is a continuous variable, X () cannote be evaluatedon a computer

The Discrete Fourier Transform (DFT) is amenable tomachine compuation

Let x [n] be defined over the interval 0, 1, . . . ,N 1 and zerootherwise

X [k]def=

N1n=0

x [n] ej2pikN

n k = 0, 1, . . . ,N 1

X [k + N] = X [k] i.e., only N distinct values are present

The X [k]s are called the DFT coefficients

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 23 / 37

• Inverse DFT

The inversion formula is

x [n] =1

N

N1k=0

X [k] e j2pikN

n

Why is the inverse x [n] and not x [n] ?

x [n + N] = x [n], i.e., inverse is periodic with period N

x [n] = x [n] for n = 0, 1, . . . ,N 1Even though we start off with an aperiodic signal, the inversetransform gives a periodic signal

But over the fundamental period, the inverse transform equalsthe original aperiodic signal

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 24 / 37

• DFT = Sampled Version of DTFT

Recall

X () =N1n=0

x [n] ejn

Evaluate X () at N uniformly spaced points in the interval[0, 2pi), i.e.,

X ()|= 2pikN

=N1n=0

x [n] ej2pikN

n

= X [k]

DFT coefficients can be viewed as samples of X ()

Since X ( + 2pi) = X (), the samples of X () are alsoperiodic

provides another explanation for why X [k + N] = X [k]

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 25 / 37

• Frequency domain sampling introducestime-domain periodicity!

Sampling in the frequency domain leads to periodic repetitionin the time domain

Repetition period is N

If we sample the DTFT at L (> N) points, the repetitionperiod will be L (> N)

If x [n] is of duration N, then X () has to be sampled at leastat N points to avoid aliasing in the time domain

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 26 / 37

X () =N1n=0

x [n]ejn

Append L N zeros x [n] and compute the L-point DFT ofthe padded sequence

This is equivalent to sampling X () at L (> N) points:

X [k] =N1n=0

x [n] ej2pink/L k = 0, 1, . . . , L 1

The underlying X () remains the same, since it depends onlyon x [n], n = 0, 1, . . . ,N 1

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 27 / 37

• Example

0 500 1000 1500 2000 2500 3000 3500 40000

1

2

3

4

5

6

7

8

9

Frequency (Hz)

Magnitude

16-pt DFT of x [n] = sin(2pin/8) n = 0, 1, . . . , 15

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 28 / 37

• Example

0 500 1000 1500 2000 2500 3000 3500 40000

1

2

3

4

5

6

7

8

9

Frequency (Hz)

Magnitude

32-pt DFT of x [n]: 16 signal samples padded with 16 zeros

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 29 / 37

• Example

0 500 1000 1500 2000 2500 3000 3500 40000

1

2

3

4

5

6

7

8

9

Frequency (Hz)

Magnitude

64-pt DFT of x [n] (zero-padded)

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 30 / 37

• Example

0 500 1000 1500 2000 2500 3000 3500 40000

2

4

6

8

Frequency (Hz)

Magnitude

DTFT of x [n] = sin(2pin/8)

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 31 / 37

• Example

0 500 1000 1500 2000 2500 3000 3500 40000

2

4

6

8

Frequency (Hz)

Magnitude

DTFT and 16-pt DFT

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 32 / 37

• Example

0 500 1000 1500 2000 2500 3000 3500 40000

2

4

6

8

Frequency (Hz)

Magnitude

DTFT and 32-pt DFT

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 33 / 37

• Example

0 500 1000 1500 2000 2500 3000 3500 40000

2

4

6

8

Frequency (Hz)

Magnitude

DTFT and 64-pt DFT

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 34 / 37

• Relationship Between Analog and Digital Spectra

Recall x [n] = x(nTs)

x(t)CTFT X ()

x [n]s DTFT X () is related to x(t)s CTFT X () as follows:

Amplitude scaling by 1Ts

Periodic repetition due to sampling

Frequency axis scaling by Fs =1Ts

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 35 / 37

• Relationship Between Analog and Digital Frequencies

A frequency 0 (f0) in the DTFT corresponds to 0 Fs rad/s(f0 Fs Hz)

Converting DFT bin to digital and analog frquencies:

Let X [k] be an N-point DFT. The digital and analogfrequencies corresponding to bin k are:

0-based index:k

N

k

N Fs Hz

1-based index:k 1N

k 1N Fs Hz

If Fs is not known, it is not possible to know the true analogfrequency given knowledge about DTFT/DFT

C.S. Ramalingam (EE Dept., IIT Madras) Introduction to DTFT/DFT 36 / 37