Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1...

39
6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Transcript of Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1...

Page 1: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

6.003: Signal Processing

Using the Discrete Fourier Transform

1 October 2020

Page 2: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Single Sinusoid

x1[n] = cos( 8π

100n)

X1[k] = DFTx1[0 : 100]

Which values of k are non-zero?

Page 3: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Next, consider a signal x5[·], described by:

x5[n] = cos(

8π100n

)+ cos

(9π100n

)

x5[n] = cos(8πn/100) + cos(9πn/100)

Page 4: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Consider analyzing with N = 100 to find the frequencies:

x5[n] = cos(8πn/100) + cos(9πn/100)∣∣X5[k]

∣∣

Page 5: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

N = 100 zoomed

x5[n] = cos(8πn/100) + cos(9πn/100)∣∣X5[k]

∣∣

Really hard to tell if this is one peak or two!

How can we do better?

Page 6: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

What is the minimum window size N needed to resolve Ω = 8π/100from 9π/100?

x5[n] = cos(8πn/100) + cos(9πn/100)

Page 7: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Two frequencies can look like one if analysis window is too small.

N = 100

x5[n] = cos(8πn/100) + cos(9πn/100)∣∣X5[k]

∣∣

Page 8: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Two frequencies can look like one if analysis window is too small.

N = 100 zoomed

x5[n] = cos(8πn/100) + cos(9πn/100)∣∣X5[k]

∣∣

Page 9: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Two frequencies can look like one if analysis window is too small.

N = 200

x5[n] = cos(8πn/100) + cos(9πn/100)∣∣X5[k]

∣∣

Page 10: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Two frequencies can look like one if analysis window is too small.

N = 200 zoomed

x5[n] = cos(8πn/100) + cos(9πn/100)∣∣X5[k]

∣∣

Page 11: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Two frequencies can look like one if analysis window is too small.

N = 400

x5[n] = cos(8πn/100) + cos(9πn/100)∣∣X5[k]

∣∣

Page 12: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Two frequencies can look like one if analysis window is too small.

N = 400 zoomed

x5[n] = cos(8πn/100) + cos(9πn/100)∣∣X5[k]

∣∣

These frequencies are barely resolved with N = 200.

Page 13: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Frequency Scales

We can think of the DFT as having spectral resolution of

(2π/N) radians in DT, which is equivalent to (fs/N) Hz in CT.

−π 0 π Ω [rad/sample]

−N/2 N/2 k

−fs/2 fs/2 f [Hz]

Page 14: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Analyzing Signals with Multiple Frequencies

Two frequencies are resolved if they are separated by more than 2πN .

Ω1 = 8π100 and Ω2 = 9π

100 will be resolved if

∆Ω = Ω2 − Ω1 = 9π100 −

8π100 = π

100 >2πN

That is, if N > 200.

We can think of 2πN as the frequency resolution of the DFT.

Notice 8 full cycles of Ω1 and 9 full cycles of Ω2 fit in N = 200.

Page 15: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Frequency Resolution

How many Fourier components are in a signal?

What are their amplitudes and frequencies?

Example: cello

Listen to the wav file cello3.wav (fs = 44,100 Hz).

How can we characterize the frequency components?

Page 16: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Frequency Resolution

Extract 1024 samples and calculate DFT (using FFT algorithm).

x[n]∣∣X1[k]

∣∣

Does it matter which part of the wav file we take the samples from?

Why use 1024 samples?

Would more be better? Would fewer be better?

Page 17: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Frequency Resolution

Most of structure is in low frequencies. Zoom in on that part.

x[n]∣∣X1[k]

∣∣

What value of k corresponds to the big peak?

What is corresponding value of frequency (in Hz)?

Page 18: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Improving Frequency Resolution

The DFT provides integer resolution in k. Therefore, the peak at

k = 7 could be off by as much as ±12 .

To improve frequency resolution, increase length of analysis window.

Two methods

• Zero padding

• Longer sequence

Page 19: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Zero Padding

Original (N=1024).

x1[n]∣∣X1[k]

∣∣

Page 20: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Zero Padding

Lengthen by a factor of 2 (N=2048).

x2[n]∣∣X2[k]

∣∣

What (if any) relations exist between |X2[k]| (this slide) and |X1[k]|(previous slide)?

Page 21: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Zero Padding

Lengthen by a factor of 4 (N=4096).

x3[n]∣∣X3[k]

∣∣

Page 22: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Zero Padding

Lengthen by a factor of 8 (N=8192).

x4[n]∣∣X4[k]

∣∣

The stem plots can be distracting when they are close together.

(They also take a long time to compute!)

Replot using lines (but remember that the signals are DT).

Page 23: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Zero Padding

Original (N=1024).∣∣X1[k]∣∣ ∣∣X1[k]

∣∣

Page 24: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Zero Padding

Lengthen by a factor of 2 (N=2048).∣∣X2[k]∣∣ ∣∣X2[k]

∣∣

Page 25: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Zero Padding

Lengthen by a factor of 4 (N=4096).∣∣X3[k]∣∣ ∣∣X3[k]

∣∣

Page 26: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Zero Padding

Lengthen by a factor of 8 (N=8192).∣∣X4[k]∣∣ ∣∣X4[k]

∣∣

Peak is now at k = 55 suggesting that analysis for N = 1024 (i.e.,

k = 7) was only approximate. Here we would get k1024 = 558 = 6.875.

Page 27: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Conclusion

Padding with zeros allowed us to compute more samples in fre-

quency.

The greater number of samples better illustrate the shape of the

window function that governs the between-frequency interpolation.

Regardless of the analysis width, resolution of the signal is deter-

mined by a square window of length 1024, since there are only 1024

samples of data available in any of the preceding analyses.

In order to increase frequency resolution, we need to include more

data.

Page 28: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Original (N=1024).

x5[n]∣∣X5[k]

∣∣

Page 29: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Lengthen by a factor of 2 (N=2048).

x6[n]∣∣X6[k]

∣∣

Page 30: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Lengthen by a factor of 4 (N=4096).

x7[n]∣∣X7[k]

∣∣

Page 31: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Lengthen by a factor of 8 (N=8192).

x8[n]∣∣X8[k]

∣∣

Switching again to line plots ...

Page 32: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Original (N=1024).∣∣X5[k]∣∣ ∣∣X5[k]

∣∣

Page 33: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Lengthen by a factor of 2 (N=2048).∣∣X6[k]∣∣ ∣∣X6[k]

∣∣

Page 34: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Lengthen by a factor of 4 (N=4096).∣∣X7[k]∣∣ ∣∣X7[k]

∣∣

Page 35: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Lengthen by a factor of 8 (N=8192).∣∣X8[k]∣∣ ∣∣X8[k]

∣∣

Page 36: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Lengthen by a factor of 16 (N=16,384).∣∣X9[k]∣∣ ∣∣X9[k]

∣∣

Page 37: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Longer Sequence

Lengthen by a factor of 32 (N=32,768).∣∣X10[k]∣∣ ∣∣X10[k]

∣∣

Clear peaks at k = 217 and k = 228 (f = 292.04 Hz and f = 306.85 Hz).

Notice that these are the second harmonics of lower frequencies.

The fundamental components were not clearly resolved with

N=1024 but are clear with N=32,768.

Page 38: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Summary: Frequency Resolution

Increasing the length of the analysis increases the number of fre-

quencies that result.

Increasing the length of the analysis by zero padding can better

illustrate the shape of the window function that governs the between-

frequency interpolation.

However, it does not increase frequency resolution.

To increase frequency resolution we must include more data.

Page 39: Using the Discrete Fourier Transform6.003: Signal Processing Using the Discrete Fourier Transform 1 October 2020

Improving Frequency Resolution

The DFT provides integer resolution in k.

To improve frequency resolution, increase length of analysis window.

Two methods

• Zero padding

− better assessment of peak frequency.

− does not improve resolution of multiple components

• Longer sequence

− improves resolution of multiple components

− averages frequency content over longer period (bad if signal

changes with time)