Presentation is loading. Please wait.

Presentation is loading. Please wait.

ME2300 DIGITAL SIGNAL PROCESSING [Slide 2] Frequency Domain Analysis BY DREAMCATCHER COURSEWARE @ https://www.dreamcatcher.asia/cw

Similar presentations


Presentation on theme: "ME2300 DIGITAL SIGNAL PROCESSING [Slide 2] Frequency Domain Analysis BY DREAMCATCHER COURSEWARE @ https://www.dreamcatcher.asia/cw"— Presentation transcript:

1 1 ME2300 DIGITAL SIGNAL PROCESSING This courseware product contains scholarly and technical information and is protected by copyright laws and international treaties. No part of this publication may be reproduced by any means, be it transmitted, transcribed, photocopied, stored in a retrieval system, or translated into any language in any form, without the prior written permission of Acehub Vista Sdn. Bhd. or their respective copyright owners. The use of the courseware product and all other products developed and/or distributed by Acehub Vista Sdn. Bhd. are subject to the applicable License Agreement. For further information, see the Courseware Product License Agreement. http://dreamcatcher.asia/cw

2 2 2. Frequency Domain Analysis

3 3 Fourier Transform: Background Fourier analysis is named after Jean Baptise Joseph Fourier (1768-1830) who claimed that any continuous periodic signal could be represented as the sum of properly chosen sinusoidal waves. His paper was disapproved by Joseph Louis Lagrance (1736-1813) who claimed that a summation of sinusoids cannot form a signal with a corner. The Fourier decomposition of a signal is illustrated in the next few slides.

4 4 Fourier Analysis The signal shown above can be decomposed into nine cosine and sine waves as shown in the next two slides. U5f1.m y[n]y[n] y[n] = c 0 [n] + c 1 [n] + … + c 8 [n] + s 0 [n] + s 1 [n] + … + s 8 [n]

5 5 U5f1.m c0[n]c0[n]c1[n]c1[n] c2[n]c2[n] c3[n]c3[n]c4[n]c4[n] c5[n]c5[n] c6[n]c6[n]c7[n]c7[n] c8[n]c8[n] Cosine waves Fourier Analysis

6 6 s0[n]s0[n]s1[n]s1[n] s2[n]s2[n] s3[n]s3[n]s4[n]s4[n] s5[n]s5[n] s6[n]s6[n]s7[n]s7[n] s8[n]s8[n] Sine waves U5f1.m Fourier Analysis

7 7 Why are sinusoids used for the decomposition instead of say square or triangular waves? The goal of decomposition is to end up with signals which are easier to deal with than the original signal. An impulse decomposition for example, enables signals to be examined at any point in time leading to the powerful convolution technique. Sinusoids are simple because they have the property: sinusoidal fidelity. A sinusoidal input to an LTI system always results in sinusoidal output with frequency & waveform unchanged and phase & amplitude possibly changed. A signal can be decomposed into sinusoidal components and the response of the system to the signal can be obtained from output sinusoids by superposition. If an input signal and the LTI system are described in the frequency domain, the output signal spectrum is obtained by multiplication which is simpler than a time-domain convolution. Fourier Analysis

8 8 A signal can be continuous or discrete. It can be periodic or aperiodic. Fourier transform can be categorized based on the signal type: Aperiodic-Continuous It extends into positive and negative infinity without repeating in a periodic pattern e.g. y = e –x and y = x 2. Fourier transform of such signal: Fourier Transform. Periodic-Continuous It repeats itself in a regular pattern between positive and negative infinity e.g. y = sin(x) and square waves. Fourier transform of such signal: Fourier Series. Fourier Analysis: Types

9 9 Aperiodic-Discrete Defined at discrete points between positive and negative infinity not repeating in a periodic pattern. Fourier transform of such signal: Discrete-Time Fourier Transform (DTFT). Periodic-Discrete A discrete signal that repeats itself in a regular pattern between positive and negative infinity. The Fourier transform of such signal: Discrete Fourier Transform (DFT). These four classes of signal extend to positive and negative infinity. How about signals with finite length?

10 10 There are two ways to get around this: Assume that the finite length signal extends infinitely to positive and negative with zero values. The signal will look aperiodic and discrete. Thus DTFT can be applied. Assume that the signal repeats itself to positive and negative infinitely. The signal will look periodic and discrete. Thus DFT can be applied. It turns out that an infinite number of sinusoids are required to synthesize a signal that is aperiodic. This makes it strictly impossible to calculate DTFT of such signal in computer algorithm. The only type of Fourier transform that can be used in DSP is thus the DFT. Fourier Analysis: Types

11 11 Fourier Analysis: Types Duality of the properties of discreteness and periodicity If the signal representation in one domain has either (or both) of those properties, then its transform representation to the other domain has the other property (or both). [Source: http://en.wikipedia.org/wiki/Fourier_analysis]

12 12 Discrete Fourier Transform (DFT) The DFT of the signal x[n] (of N sample values in a period) is generated as follows * : Usually the following notation is used: Thus we can also write X[k] as follows: * Uppercase letters are usually used for the frequency-domain representation.

13 13 Discrete Fourier Transform (DFT) The values of X[k] obtained are as shown below: X[k]X[k] kRealImaginary 00.42860 10.3018 –0.1087 20.78640.3848 3 –0.3025–0.6688 4 –0.30250.6688 5 0.7864–0.3848 6 0.30180.1087 Symmetrical Therefore, only N values are sufficient to represent the real and imaginary parts of X[k]. X[0] is always real and thus there is no need to explicitly specify its imaginary part (= 0). Anti-symmetrical Example 1: Perform DFT on the x[n] = [2 1 –2 3 –1 –1 1] N = 7 ( odd )

14 14 U5f2.m (I) Time domainFreq. domain - real Freq. domain - imag Freq. domain - abs DFT Example 1

15 15 The values of X[k] obtained are as shown below: X[k]X[k] kRealImaginary 0–0.87500 1–0.6705 –0.7740 20–0.6250 3 0.9205–1.5240 4 0.37500 5 0.92051.5240 600.6250 7–0.67050.7740 Symmetrical Only N values are sufficient to represent the real and imaginary parts of X[k]. Anti-symmetrical Example 2: Perform DFT on the x[n] = [0 1 –2 3 –1 –1 1 –8] N = 8 (even) Discrete Fourier Transform (DFT)

16 16 The real and imaginary parts of X[k] are normally referred as Re X[k] and Im X[k] respectively. A periodic digital signal with N samples per period can be completely specified in the frequency domain by a set of N consecutive harmonics: N/2 + 1 comes from the real parts while N/2 – 1 comes from the imaginary parts if N is even. (N + 1)/2 comes from the real parts while (N + 1)/2 – 1 comes from the imaginary parts if N is odd. Previous examples, N = 7: 4 and 3 real and imaginary spectral components; N = 8: 5 and 3 real and imaginary spectral components. Discrete Fourier Transform (DFT)

17 17 The horizontal axis of the frequency domain can be referred to in four different ways. 1)The first way is the one shown in the previous examples in which the index for the frequency domain is an integer, k (which runs from 0 to N – 1). 2)The second way is the one in which the horizontal axis is labelled as a fraction of the sampling rate. The horizontal values thus run from 0 (k = 0) to 0.5 (k = (N – 1)/2)* and then to 1 (k = N – 1). The notation used for the horizontal index is f = k/N. 3)The third way is the same as the second way except that it is multiplied by 2 . The index used is  with  = 0 to  (for k = 0 to (N – 1)/2)*. *when N is odd. DFT: Independent Variables

18 18 Test signal, x[n] N = 32 DFT: Independent Variables 4)The fourth way is to label the horizontal axis in terms of the analog frequencies used in a particular application. For example in an application with a sampling rate of 10 kHz will have the horizontal index running from 0 (k = 0) to 5 kHz (k = (N – 1)/2 )*. U5f3.m

19 19 DFT of x[n]: The horizontal axis is labeled using integers. Re X[k] Im X[k] U5f3.m N = 32 DFT: Independent Variables

20 20 DFT of x[n]: The horizontal axis is labeled as f (fraction of sampling frequency). Re X[f] Im X[f] U5f3.m Sampling frequency½ Sampling frequency DFT: Independent Variables

21 21 DFT of x[n]: The horizontal axis is labeled as  (radians). Re X[  ] Im X[  ] U5f3.m 22 DFT: Independent Variables

22 22 DFT of x[n]: The horizontal axis is labeled in terms of kHz. Re X[freq] Im X[freq] U5f3.m Sampling frequency½ Sampling frequency DFT: Independent Variables

23 23 DFT: Periodic Signals Consider a periodic discrete-time signal: We can expand the equation into a complex exponential series: The Fourier series coefficients are: a –2 = 1, a –1 = j/2, a 0 = 4, a 1 = –j/2, a 2 = 1.

24 24 DFT: Periodic Signals DFT of N = 16 in MATLAB fft(x, N) A C B L = NL = 2N

25 25 DFT: Periodic Signals sin 2 A = (1 – cos2A)/2 cos 2 A = (1 + cos2A)/2 DFT 4N = 64 for N = 16 jN/2 = j8 for N = 16 N = 16 Sequence length, L = N A B C

26 26 DFT: Periodic Signals For cases of L > N, fft(x, N) in MATLAB simply truncates the signal x to first N samples. Thus, fft in the previous example for L = 2N = 32 is the same as L = N = 16 as the fft takes into account the same first 16 samples of x in both cases. For cases of L < N, fft(x, N) in MATLAB simply pad zeros to x to make up the length of N. See next slide. Note that the spectral for cases of L < N are different compared to cases of L ≥ N before. Reason: padding of zeros changes the signal by adding other spectral components.

27 27 DFT of N = 32 in MATLAB fft(x, N) L = N/2 L = N (padding) DFT: Periodic Signals Adding other spectral components

28 28 DFT: Aperiodic Signals x = sin(n  /8) × sin(n  /4) DFT of N = 16 in MATLAB fft(x, N) L = NL = 2N

29 29 DFT: Aperiodic Signals DFT of N = 32 in MATLAB fft(x, N) L = N/2 L = N (padding) Adding other spectral components x = sin(n  /8) × sin(n  /4)

30 30 Signal Spectrum: Odd / Even Signals Even Signal An even signal x[n] is such that x[n] = x[–n] i.e. it is symmetrical about n = 0. Example: sequence x[n] = {–2.5 0.5 1.0 –2.0 –2.0 1.0 0.5} x[n]x[n]

31 31 Re X[k] Im X[k] It is clear from the diagram above that x[n] has zero imaginary part. Therefore even signals always have zero sine component (imaginary part). Signal Spectrum: Odd / Even Signals

32 32 Odd Signal An odd signal x[n] is such that x[n] = –x[–n] i.e. it is anti- symmetrical about n = 0. Example: x[n] = {0 0.5 1.0 –2.0 2.0 –1.0 –0.5} Signal Spectrum: Odd / Even Signals

33 33 It is clear from the diagram above that x[n] has zero real part. Therefore odd signals always have zero cosine component (real part). Signal Spectrum: Odd / Even Signals

34 34 DFT Computation Using MATLAB There are four built-in functions in MATLAB that can be used for DFT analysis: fft(x), fft(x, N), ifft(X), ifft(X, N) fft(x) computes the R-point DFT of a vector x of length R. fft(x, N) truncates vector x to its first N points and computes the DFT of the truncated vector which is of N samples if N < R. fft(x, N) zero-pads vector x to N points and computes the DFT of the extended vector which is of N samples if N > R. DFT in MATLAB

35 35 ifft(x) computes the R-point IDFT of a vector x of length R. ifft(x, N) truncates vector x to its first N points and computes the IDFT of the truncated vector which is of N samples if N < R. ifft(x, N) zero-pads vector x to N points and computes the IDFT of the extended vector which is of N samples if N > R. DFT in MATLAB

36 36 Signal Spectrum: Magnitude and Phase With a signal having a spectrum with both real and imaginary parts, we can express each of its spectrum components in terms of magnitude and phase. The magnitude of a spectral component is given by The phase of a spectral component is given by For the signal x[n] in U5f3.m, the magnitude and phase of its spectral components are shown in the next slide.

37 37 Signal Spectrum: Magnitude and Phase DFT of N = 16 in MATLAB fft(x, N) L = N x = sin(n  /8) × sin(n  /4)

38 38 Let’s consider another example: for 0  n  63 The four components have 64, 16, 8, and 4 samples per period. These correspond to the fundamental, 4th, 8th, and 16th harmonics. x[n]x[n] Signal Spectrum: Magnitude and Phase

39 39 As expected, the magnitudes of the spectral coefficients have values of 0.5, 0.5, 0.3, & 0.25 at k = 1, 4, 8, & 16, and their ‘mirror images’ representing the 1st, 2nd, 3rd, and 4th terms of the x[n] shown above. Signal Spectrum: Magnitude and Phase 0.5 0.3 0.25 0.3 0.5 |X[k]| kk –  /2  /2

40 40 There are two sinusoidal terms and thus we have phase values of  /2 at k = 1, 16 and their ‘mirror images’. The two cosinoidal terms result in zero phase values at k = 4, 8 and their ‘mirror images’. The four frequency components of x[n] complete integral number of cycles between n = 0 to 63. How will the spectra look like if we have frequency components with non-integral number of cycles within the same range? Consider the DFT of the following signal: Signal Spectrum: Magnitude and Phase

41 41 fft(x, N) L = N Signal Spectrum: Magnitude and Phase AB Discontinuity

42 42 For the case of A, the sinusoidal signal completes exactly two cycles within 16 samples of signal x. The magnitude spectrum shows a single spectral component at k = 2 (DFT of length 16 results in eight spectral line ticks between 0 and  of the signal angular frequency range; x has an angular frequency of  /4 and thus makes up the spectral component at k = [(  /4) /  ] × 8 = 2). For the case of B, the sinusoidal signal makes 20/8 = 2.5 cycles within 20 samples of signal x. There is discontinuity at the edge of x and this contributes to additional spectral components (undesired). See next slide. Signal Spectrum: Magnitude and Phase

43 43 DFT inherently assumes that signals under analysis are periodic. Discontinuity Signal Spectrum: Magnitude and Phase

44 44 The DFT of a unit impulse is as shown in the next slide. The signal energy is evenly distributed in the frequency domain as shown in the next slide. This is why the response of an LTI discrete-time system to a unit impulse is used to describe the system. x[n]x[n] Signal Spectrum: Unit Impulse Unit impulse

45 45 A unit impulse simply delivers an equal amount of signal energy at all frequencies to the LTI discrete- time system. Zero phase Signal Spectrum: Unit Impulse

46 46 The phases of the spectral coefficients are zero. This is because the impulse train that we consider here is an even function of n. (In DFT, we always assume that the signals are periodic). Having x 1 [n] periodic every 16 samples will give us an even periodic signal, x 2 [n] as shown above. This is the actual signal we assume in the DFT of x 1 [n]. Signal Spectrum: Unit Impulse

47 47 DFT of the Delayed Unit Impulse Shown in the next slide are x 1 [n], x 2 [n], and x 3 [n] which are delayed versions of the unit impulse, x[n] by one, two, and four samples respectively. It is clear that the magnitudes of the spectral coefficients are the same as that of x[n] i.e. |X 1 [k]| = |X 2 [k]| = |X 3 [k]| = |X[k]|. However, the phase of the spectral coefficients exhibits a linear relationship with frequency. The slope of the phase characteristic is proportional to the time-shift introduced. Signal Spectrum: Unit Impulse (Delayed)

48 48 Signal Spectrum: Unit Impulse (Delayed) x 1 [n] =  [n – 1]x 2 [n] =  [n – 2]x 3 [n] =  [n – 4]

49 49 Signal Spectrum: Unit Impulse (Delayed)

50 50 Linear convolution is a key operation in most signal processing applications. Since DFT can be implemented very efficiently as we will see later, it is of interest to investigate methods for implementation of linear convolution using DFT. Linear Convolution of Two-Finite Length Sequences Let g[n] and h[n] be finite-length sequences of lengths N and M. Denote L = M + N – 1. Define two length-L sequences: Linear Convolution Using DFT

51 51 Then, y L [n] = g[n] * h[n] = y C [n] = g[n] h[n] Zero- padding (N+M–1)- point DFT (N+M–1)- point IDFT g[n]g[n] h[n]h[n] ge[n]ge[n] he[n]he[n] Ge[k]Ge[k] He[k]He[k] yL[n]yL[n] DFT-based implementation of the linear convolution of two finite-length sequences L Linear Convolution Using DFT

52 52 Linear Convolution Using DFT

53 53 X 1 [k] X 2 [k]N-point circular convolution X[k – k0N]X[k – k0N] Circular frequency-shifting x[n – n0N]x[n – n0N] Circular time- shifting a X 1 [k] + b X 2 [k]a x 1 [n] + b x 2 [n]Linearity x 1 [n] x 2 [n]Modulation N-point DFT X 1 [k], X 2 [k]Length-N sequence x 1 [n], x 2 [n] Property Table 1 General Properties of DFT

54 54 X 3 [k] = X 1 [k]+X 2 [k] General Properties of DFT: Linearity

55 55 [1, –j, –1, j, 1, –j, –1, j, …] × General Properties of DFT: Time Shifting

56 56 [1, -j, -1, j, 1, -j, -1, j, …] × Re Imag General Properties of DFT: Frequency Shifting

57 57 × X 3 [k] = X 1 [k]·X 2 [k]x 3 [n] = conv c (x 1 [n]*x 2 [n]) General Properties of DFT: Convolution

58 58 x 3 [n] = x 1 [n]·x 2 [n]X 3 [k] = conv c (X 1 [k]*X 2 [k]) General Properties of DFT: Modulation

59 59 g[n] h[n] Linear convolution between two N-length sequences, g[n] and h[n] results in a (2N – 1)-length sequence, y L [n]: To develop a convolution-like operation resulting in a length- N sequence y C [n], we need to define a circular time-reversal and then apply a circular time-shift. The resulting operation is circular convolution: Like linear convolution, circular convolution is commutative: N g[n] h[n]=h[n] g[n] N N Circular Convolution

60 60 Example: Perform linear and circular convolutions between g[n] = [1 2 0 1] and h[n] = [2 2 1 1]. [ 1 2 0 1 ] [ 1 1 2 2 ] [ 2 0 0 0 ] [ 1 2 0 1 ] [ 1 1 2 2 ] [ 2 4 0 0 ] [ 1 2 0 1 ] [ 1 1 2 2 ] [ 1 4 0 0 ] [ 1 2 0 1 ] [ 1 1 2 2 ] [ 1 2 0 2 ] [ 1 2 0 1 ] [ 1 1 2 2 ] [ 0 2 0 2 ] [ 1 2 0 1 ] [ 1 1 2 2 ] [ 0 0 0 1 ] [ 1 2 0 1 ] [ 1 1 2 2 ] [ 0 0 0 1 ] 2 4 6 1 5 1 5 [ 1 2 0 1 ] [ 2 1 1 2 ] [ 1 2 0 2 ] 6 [ 1 2 0 1 ] [ 2 2 1 1 ] [ 2 4 0 1 ] 7 [ 1 2 0 1 ] [ 1 2 2 1 ] [ 1 4 0 1 ] 6 [ 1 2 0 1 ] [ 1 1 2 2 ] [ 1 2 0 2 ] 5 Circular convolution: Linear convolution: Circular Convolution

61 61 We can make use of the circular convolution property shown in Table 1 (slide 53) to determine the circular convolution between g[n] and h[n]. y[n] can be obtained by generating the inverse DFT of Y[k] as shown in the next slide. U5f2a.m Circular Convolution

62 62 Circular Convolution

63 63 Example: Extend the sequences g[n] and h[n] to length 7 as follows: [ 1 2 0 1 0 0 0 ] [ 2 0 0 0 1 1 2 ] 2 [ 2 0 0 0 0 0 0 ] [ 1 2 0 1 0 0 0 ] [ 2 2 0 0 0 1 1 ] 6 [ 2 4 0 0 0 0 0 ] [ 1 2 0 1 0 0 0 ] [ 1 2 2 0 0 0 1 ] 5 [ 1 4 0 0 0 0 0 ] [ 1 2 0 1 0 0 0 ] [ 1 1 2 2 0 0 0 ] 5 [ 1 2 0 2 0 0 0 ] [ 1 2 0 1 0 0 0 ] [ 0 1 1 2 2 0 0 ] 4 [ 0 2 0 2 0 0 0 ] [ 1 2 0 1 0 0 0 ] [ 0 0 1 1 2 2 0 ] 1 [ 0 0 0 1 0 0 0 ] [ 1 2 0 1 0 0 0 ] [ 0 0 0 1 1 2 2 ] 1 [ 0 0 0 1 0 0 0 ] The result is the same as the linear convolution. Circular Convolution

64 64 Symmetry properties of the DFT of a complex sequence Length-N sequenceN-point DFT x[n]x[n]X[k]X[k] x*[n] X*[  –k  N ] x*[  –n  N ] X*[k] Re{ x[n] } X pcs [k] = ½{ X[  k  N ] + X*[  –k  N ] } j Im{ x[n] } X pca [k] = ½{ X[  k  N ] – X*[  –k  N ] } x pcs [n] Re{ X[k] } x pcs [n] and x pca [n] are the periodic conjugate-symmetric and periodic conjugate anti- symmetric parts of x[n]. Likewise, X pcs [k] and X pca [k] are the periodic conjugate symmetric and periodic conjugate anti-symmetric parts of X[k]. j Im{ X[k] } x pca [n] DFT Properties

65 65 Symmetry properties of the DFT of a real sequence Length-N sequenceN-point DFT x[n]x[n]X[k] = Re{X[k]}+j Im{X[k]} x pe [n] Re{ X[k] } j Im{ X[k] } x po [n] X[k] = X*[  –k  N ] Re{X[k]} = Re{X[  –k  N ]} Im{X[k]} = –Im{X[  –k  N ]} |X[k]| = |X[  –k  N ]| arg{X[k]} = arg{X[  –k  N ]} Symmetry Relations Note: x pe [n] and x po [n] are the periodic even and odd parts of x[n]. DFT Properties

66 66 The DTFT is the Fourier transform of a discrete-time sequence x[n]. It is a representation of the sequence in terms of the complex exponential sequence {e –j  n } where  is a real frequency variable. The DTFT representation of a sequence, if exists, is unique and the original sequence can be computed from its DTFT by an inverse transform operation. The DTFT of a sequence x[n] is given by In general, X(e j  ) is a complex function of the real variable  and can be expressed as Discrete-Time Fourier Transform (DTFT)

67 67 where X re (e j  ) and X im (e j  ) are the real and imaginary parts of X(e j  ) and are the real functions of . |X(e j  )| and  (  ) are referred to as the magnitude spectrum and phase spectrum respectively. Example: Consider a causal sequence x[n] = (0.5) n  [n] Sum of convergent geometric series and thus can be expressed in a closed form Discrete-Time Fourier Transform (DTFT)

68 68 DTFT: Example x[n] = (0.5) n  [n]

69 69 It is clear that the Fourier transform X(e j  ) of a sequence x[n] is A continuous function of . A periodic function in  with a period of 2 . We can compute x[n] from X(e j  ) using the Fourier integral given by DTFT pair: DTFT and Inverse

70 70 Relation between DTFT and DFT DFT is a simpler version of the relation between DTFT and the finite-length discrete-time sequence. It is obtained by sampling X(e j  ) on the  -axis between 0    2  at  k = 2  k/N, k = 0, 1, …, N – 1. Given length-N, x[n], it is possible to determine a ‘denser’ version of the N-length, DFT of the sequence using the same numerical technique such as DFT and thus approaching X(e j  ). ** DFT is assumed without the (1/N) scaling factor for this section. DTFT and DFT Relationship

71 71 Let X(e j  ) be the DTFT of a length-N sequence x[n]. We wish to evaluate X(e j  ) at  k = 2  k/M, k = 0, 1, …, M – 1 where M >> N. Define a new sequence: We thus obtain: which is an M-point DFT of x e [n] i.e. X e [k]. The DFT X e [k] can be computed very efficiently using the FFT algorithm if M is an integer power of 2. Extending x[n] for the DTFT computation DTFT and DFT Relationship

72 72 DTFT and DFT Relationship X[k]X[k] X[ej]X[ej] The graph below shows the DFT (16 samples) and DTFT (512 samples) of length-16 x[n]. DTFT is carried out by zero-padding x[n] to length-512 before applying FFT. x[n] = cos(2  n3/16).

73 73 x[n]x[n]|X(e j  )| x[n]x[n] DTFT DTFT: Examples

74 74 x1[n]x1[n] |X 1 (e j  )| 1(ej)1(ej) x2[n]x2[n] |X 2 (e j  )| 2(ej)2(ej) DTFT of the unit impulse sequence (aperiodic): without delay and with delay DTFT: Examples

75 75 DTFT of an aperiodic sequence beginning at a non-zero position. What we have seen thus far are aperiodic sequences starting at n equal to zero. The function fft used assumes that the sequence starts at n = 0. To use the function to compute the DTFT of an aperiodic sequence starting at non-zero n, we need to modify the input sequence to the function. Example: Determine DTFT of sequence, x[n] = [ 1 2 3 4 5 ]. Assume that we determine DTFT through DFT of length of 500. If the sequence is x1[n] = [ 1 2 3 4 5 ] then we just need to pad extra 495 zeros to x 1 to be the input to fft e.g. fft( [ x1 zeros(1,495)] ). However, for the case of x, we require the following: fft( [ x1(2:5) zeros(1,495) x1(1)] ). DTFT: Sequence Starting at n ≠ 0

76 76 DTFT of x 1 = { 1 2 3 4 5 }. fft( [ x1 zeros(1,495)] ). DTFT: Sequence Starting at n = 0

77 77 DTFT: Sequence Starting at n ≠ 0 DTFT of x = { 1 2 3 4 5 }. fft( [ x1(2:5) zeros(1,495) x(1)] ).

78 78 In general, we have to define the input sequence to fft as x in = { x(n=0) x(n=1) x(n=2) … x(n=N-n’) … x(n=–n’) x(n=–n’+1) … x(n=–1) } where N is the sequence length and n’ is a positive integer. In DFT we assume that the sequence is periodic. Therefore by presenting the above input into fft, we actually perform transformation for the following periodic sequence: 1 2 3 4 5 0 0 … 0 0 1 2 3 … n = 0 period The padded zeros allow us to estimate DTFT from DFT using the function fft. DTFT: Sequence Starting at n ≠ 0

79 79 x[n] =1, |n|  m x[n] =0, |n| > m [n][n] 1 [n][n] Fourier transformSequence DTFT: Common Transform Pairs

80 80 DFT and DTFT share the same set of properties with minor differences. a X 1 (e j  ) + b X 2 (e j  )a x 1 [n] + b x 2 [n]Linearity X(ej)X(ej)Inverse transformation x[n]x[n]Transformation x[n - n 0 ]Time-shifting Fourier transformAperiodic signalProperty or operation DTFT: Properties 1

81 81 X 1 (e j  ) X 2 (e j  )x 1 [n] * x 2 [n]Convolution x 1 [n] x 2 [n]Modulation X(e j  ) (1 – e –j  )x[n] – x[n – 1]Time- differentiation Parseval’s relation: DTFT: Properties 2

82 82 jX im (e j  )x ca [n] X re (e j  )x cs [n] X ca (e j  ) = (1/2){ X(e j  ) – X*(e –j  ) }jIm{x[n]} X*(e j  )x*[–n] X cs (e j  ) = (1/2){ X(e j  ) + X*(e –j  ) }Re{x[n]} X(e–j)X(e–j)X[–n]X[–n] Fourier transformSequence X cs (e j  ) and X ca (e j  ) are the conjugate-symmetric and conjugate anti- symmetric parts of X(e j  ). x cs [n] and x ca [n] are the conjugate-symmetric and conjugate anti-symmetric parts of x[n]. DTFT: Symmetry Relation of Complex Sequences

83 83 An important application of DSP methods is in determining in the discrete-time domain the frequency contents of a continuous-time signal: frequently known as spectral analysis. One way of spectral analysis on a continuous-time signal g a (t) is to compute the DTFT, G(e j  ) of its discrete-time equivalent g[n]. However, g a (t) is defined for –  < t <  and so is g[n] which is defined for –  < n < . Furthermore, DTFT is a continuous function of  and its exact evaluation is not feasible in general. A more practical approach: Anti-aliasing filter g(t)g(t) ADCWindowing g[n]g[n] DFT [n][n] [k][k] Length N Set of R angular frequencies equally spaced in 0    . Spectral Analysis of Signals

84 84  [k] is related to  [e j  ], DTFT of  [n] as follows: Example: Consider an infinite-length sequence g[n]: The DTFT of g[n] is given as which is a periodic function of  with the period 2  containing two impulses in each period. Impulses of amplitude  e j  and  e –j  at  =  0 and  = –  0. To analyze DFT of g[n], we employ a finite-length version of g[n]:  [n] = cos(  0 n +  ), 0  n  N – 1 Spectral Analysis of Signals

85 85 DFT of a length-32 sinusoid of frequency 10 Hz sampled at 64 Hz DFT of a length-32 sinusoid of frequency 11 Hz sampled at 64 Hz Two non-zero DFT values at k = 5 and 27 k = 5 corresponds to (64  5)/32 = 10 Hz while k = 27 corresponds to (64  –5)/32 = –10 Hz. Two pairs of strong peaks at k = 5, 6 and 26, 27 k = 5, 6 correspond to frequencies 10 Hz and 12 Hz, and k = 26, 27 correspond to frequencies –10 Hz and –12 Hz. The spread of energy from a single frequency to many DFT frequency locations is called leakage. Spectral Analysis of Signals

86 86 It can be observed that  [n] is a windowed version of the infinite- length sequence g[n] obtained using a rectangular window w[n]: The DTFT  (e j  ) of  [n] is given by the frequency-domain convolution of the DTFT G(e j  ) of g[n] with the DTFT  R (e j  ) of the window w[n]: where Substituting G(e j  ) obtained before we get Spectral Analysis of Signals

87 87 It is clear that DTFT  (e j  ) of the windowed sequence  [n] is a sum of the frequency shifted and amplitude scaled DTFT  R (e j  ) of the window w[n] with the amount of frequency shift given by  0. Spectral Analysis of Signals

88 88 For a length-32 sinusoid of frequency 11 Hz sampled at 64 Hz, the normalized frequency is 11/64 = 0.172. Hence, DTFT is obtained by frequency shifting the DTFT  R (e j  ) of a length-32 rectangular window to the right and to the left by 0.172  2  = 0.344 , adding both shifted version and amplitude scaling by a factor ½. For a normalized frequency range 0 to 2 , there are two peaks at 0.344  and 2  (1 – 0.172) = 1.656 . A 32-point DFT  [k] has strong peaks at k = 5 and 6 which are frequency samples of the main lobe located at the normalized frequency 0.172 on both sides of the peak. Likewise, the two strong peaks of DFT  [k] at k = 26 and 27 are frequency samples of the main lobe located at normalized frequency 0.828 on both sides of the peak. Spectral Analysis of Signals

89 89 All other DFT samples are given by the samples of the sidelobes of the DTFT. This causes leakage of frequency components at  0 to other k locations. The ratio of the mainlobe peak amplitude to the largest sidelobe amplitude should be relatively high, or there is a considerable amount of leakage to k locations adjacent to the peak locations. The above problem gets more complicated if the signal being analyzed consists of more than one sinusoid. We will examine the effects of the following parameters on the results of spectral analysis in the examples as follows. (1) Length R of DFT (2) Type of window (3) Length of window N Spectral Analysis of Signals

90 90 N = 16, R = 16 N = 16, R = 32N = 16, R = 64 DTFT Signal Spectral Analysis: Effect of DFT Length R

91 91 In general, an increase in the DFT length increases the resolution of the spectral analysis by reducing the spectral separation of adjacent DFT samples. N = 16, R = 128 Signal Spectral Analysis: Effect of DFT Length R

92 92 f 1 = 0.28, f 2 = 0.34 f 1 = 0.29, f 2 = 0.34 f 1 = 0.30, f 2 = 0.34 f 1 = 0.31, f 2 = 0.34 Signal Spectral Analysis: Frequency Separation

93 93 DTFT of a length-N sinusoid of normalized angular frequency  1 is obtained by frequency translating the DTFT  R (e j  ) of a length-N rectangular window to frequencies   1 and scaling their amplitudes appropriately. In the case of a sum of two length-N sinusoids of normalized frequencies  1 and  2, the DTFT is obtained by summing the DTFTs of the individual sinusoids. As the difference between the two frequencies become smaller, the mainlobes of the DTFTs of the individual sinusoids get closer and eventually overlap. Frequency resolution is therefore determined by the width  ML of the mainlobe of the DTFT of the window.  ML of the length-N rectangular window is given by 4  /N. For the example given,  ML in terms of the normalized frequency is 0.125. Hence, two sinusoids with a frequency difference of less than 0.0625 will not be clearly resolved. Signal Spectral Analysis: Frequency Separation

94 94 N = 16, R = 16 N = 16, R = 64 N = 32, R = 32N = 32, R = 64 Signal Spectral Analysis: Effects of N and R

95 95 The above graphs are DFTs of x[n] = 0.85 sin(2  f 1 n) + sin(2  f 2 n) where f 1 = 0.22 and f 2 = 0.26. For U5f21a.m (II), the Hamming window was used instead of the rectangular window [U5f21a.m (I)].  ML of the length-N Hamming window is given by 8  /N. To improve frequency resolution, one must use a window with a very small mainlobe width. To reduce leakage, one must use a window with a very small relative sidelobe level. The mainlobe width can be reduced by increasing the length of the window. (I) Rec. window (II) Hamm. window Signal Spectral Analysis: Effect of Window Types

96 96 This is an example of the DFT of a noise- corrupted sinusoid: y[n] = sin(0.1  n) + 3 v[n] where v[n] is a uniformly distributed random noise with amplitude bounded by  0.5. It is difficult to tell that (b) is a noise-corrupted sinusoid. But with the peak at k=13 and 243 of the DFT in (c), we can deduce that there is a strong sinusoidal signal at the normalized frequency 13/256 = 0.0508. (a)(b) (c) Signal Spectral Analysis: Noise-Affected Signal

97 97 STFT can be employed for spectral analysis of a finite-length signal composed of sinusoidal components as long as the frequency, amplitude, and phase of each sinusoidal component are time-invariant and independent of the signal length. There are practical situations that non-stationary signals are to be analyzed. Example: chirp signal y[n] = A cos(  0 n 2 ) Other examples: speech, radar, and sonar signals To describe such signals in the frequency domain using simple DFT is misleading. One way out: segment into sub-sequences, each centred at uniform intervals and computes their DFTs separately. Short-Time Discrete Fourier Transform (STFT)

98 98 If sub-sequences are of reasonably small, it can be safely assumed to be stationary for practical purposes. As a result, the frequency-domain description of a long sequence is given by a set of short-length DFTs i.e. time-dependent DFT. To do that we multiply the sequence with a window w[n] that is stationary in time and slide the signal through the window. Chirp signal: y[n] = cos(0.0001  n 2 ) Short-Time Discrete Fourier Transform (STFT)

99 99 Sub-sequences of the chirp signal: y[n] = cos(0.0001  n 2 ) Short-Time Discrete Fourier Transform (STFT)

100 100 The short-time Fourier transform (STFT), or alternatively, short- term Fourier transform is defined as: where w[n] is a suitably chosen window sequence. The function of a window to extract finite-length of the sequence x[n] is chosen such that the spectral characteristics of the section extracted are approximately stationary over the duration of the window for practical purposes. STFT is a function of two variables: the integer variable time index n and continuous frequency variable . To compute inverse STFT we observe that X STFT (e j , n) is the DTFT of x[n – m]w[m]: STFT: Definition

101 101 Hence, x[n] can be determined if w[0]  0. In most applications, the magnitude of STFT is of interest. The display of the magnitude of STFT is referred as the spectrogram. Shown in the next slide is the spectrogram of the chirp signal. The angular frequency is  n/512 and the sequence length is 256. The window used is the Hamming window of length 32. In the spectrogram, the large-valued DFT samples are at around the frequency of the sinusoid while at other frequencies the sample values are small. As the instantaneous frequency of the chirp signal increases linearly, the red line moves up vertically. STFT: Spectrogram

102 102 STFT: Spectrogram

103 103 In practice, the STFT is computed at a finite set of discrete values of . STFT is accurately represented by its frequency samples as long as the number of frequency samples is greater than the window length. The portion of the sequence x[n] inside the window can be fully recovered from the frequency samples of the STFT. Let the window be defined over the range 0  m  R – 1. We sample X STFT (e j , n) at N equally-spaced frequencies  k = 2  k/N, with N  R: STFT: Spectrogram (Sampling in Time & Frequency)

104 104 Assuming w[m]  0, X STFT [k,n] is simply the DFT of x[n – m]w[m]. X STFT [k,n] is a two-dimensional sequence and is periodic in k with a period N. Applying IDFT, we get We can observe from above that the sequence values inside the window can be fully recovered from X STFT [k,n] as long as the number N of frequency samples is greater than or equal to the window length R. STFT: Spectrogram (Sampling in Time & Frequency)

105 105 It is also evident that x[n] for –  < n <  can be fully recovered if X STFT [k,n] is sampled also in the time dimension. The sampled STFT for a window defined in the region 0  m  R – 1 is given by for l and k are integers such that –  < l <  and 0  k  N – 1 0 1 2 3 4 5 6 7 8 9 10 11 12 22 0  n N – 1 22 0  n k 0 1 3 l 0 0 L 1 2L2L 2 3L3L 3 2/N2/N X STFT [k,lL] for L = 4, N = 9 X STFT [k,L] X STFT [k,2L] X STFT [k,3L] X STFT (e j ,4) X STFT (e j ,8) X STFT (e j ,12) STFT: Spectrogram (Sampling in Time & Frequency)

106 106 The function of a window is to extract a portion of the signal for analysis and ensure that the extracted section of x[n] is approximately stationary. A decrease in window length, R increases the time- resolution property of the STFT. Frequency resolution increases with increase in R. Two frequency-domain parameters that characterize the DTFT of a window: main lobe width,  ML and relative sidelobe amplitude, A sl.  ML determines the ability of the window to resolve two signal components in the vicinity of each other while A sl controls the degree of leakage of one component into a nearby signal component. STFT: Spectrogram (Window Selection)

107 107 In order to obtain a reasonably good estimate of the frequency spectrum of a time-varying signal, the window should be chosen to have a small  ML and large A SL with a length chosen based on the acceptable accuracy of the frequency and time resolutions. STFT: Spectrogram (Window Selection)

108 108 In MATLAB / Octave we can use the function, spectrogram. See MATLAB Help for details of the function. STFT: Computation in MATLAB / Octave Example: Spectrogram of a speech signal given as follows: Speech signal: time-domain plotting

109 109 STFT: Computation in MATLAB Spectrogram: nfft = 256, ovlap = 64, Hamm. window (length = nfft), frequency = 7418 nfft = 64, ovlap = 16, Hamm. window (length = nfft), frequency = 7418 Take note of the trade-off between time and frequency resolutions from the above two graphs.


Download ppt "ME2300 DIGITAL SIGNAL PROCESSING [Slide 2] Frequency Domain Analysis BY DREAMCATCHER COURSEWARE @ https://www.dreamcatcher.asia/cw"

Similar presentations


Ads by Google