46 DISCRETE-SIGNAL ANALYSIS AND DESIGN lines are drawn for an |ε| value of 10 −3 . Again, the spectrum of the signal is shown at integer values of (k). If we are able to conÞne our interest to these integer values of (k), these Þgures characterize the performance of the DFT for an input that is very close in frequency to an integer (k) value. Exact values of (k) give optimum frequency resolution between adjacent values of (k), which is why they are preferred when possible. It is not always possible, as we will see in Chapter 4. Figure 3-1a and b do not tell the entire story. Assume the following x(n) complex input voltage sequence at frequency k 0 =38.0 in Eq. (3-1) x(n) = exp j2π n N k 0 ,k 0 = 38.0 (3-1) Using Eq. (1-2) for the DFT, N =128, and k =30 to 46 in steps of 0.01, the phasor frequency response X (k ) is (review p. 24) X(k) = 1 N N−1 n=0 x(n) exp −j 2π n N k = 1 N N−1 n=0 exp j2π n N k 0 exp −j 2π n N k = 1 N N−1 n=0 exp j2π n N ( k 0 − k ) (3-2) Mathcad Þnds the real part, the imaginary part and the magnitude of the complex exponential (phasor) at each non integer value of (k). Figure 3-1c shows the magnitude in dB on a 0 to −40 dB scale. This is a “selectivity” curve (ratio in dB below the peak) for the DFT. At 37.5 or 38.5, for example, the response is down 3.92 dB. An input signal at either of these frequencies will show a reduced output at 38.0 (the scalloping effect). At any other input signal frequency k 0 that lies between adjacent integer-k values, we can repeat Eq. (3-2) to Þnd the spectrum for that k 0 , and we suggest that the reader experiment with this for additional insight. The last term in Eq. (3-2) is a virtual scalar spectrum analyzer. At each 0.01 increment of frequency, it calculates and then sums, for each SPECTRAL LEAKAGE AND ALIASING 47 of 128 time values in Fig. 3-1c, the magnitude of X(k)indBbelowthe reference level (0 dB). Note that the loop width at 38 is 2.0 and other loop widths are 1.0, but the response is zero at 37 and 39. If we calculate the real and imaginary parts of the spectrum, we could have a vector network analyzer. In other words, the Mathcad Worksheet can be taught how to measure forward and reßected complex waves by using the mathematical equivalent of an ideal wideband four-port directional coupler [Sabin, 1995, p. 3]. S -parameters can be derived from these complex waves. Figure 3-1d is a close-up of the spectrum between 37 and 39, showing the magnitude, real part, and imaginary part, all in dB. It is obvious that the spectrum becomes very complex, although the magnitude decreases smoothly. At 38.5 the phase is −90 ◦ , and at 37.5 the phase is +90 ◦ ,(the graph shows only magnitudes in dB). At 37.0, 38.0 and 39.0 the phase is 0.0 ◦ . The magnitude plot is the same as that in Fig. 3-1c over the same frequency range. Further mathematical discussion of these waveforms involves the sinc function (see, for example, [Carlson, 1986, p. 25]). Methods of reducing the leakage by windowing will be covered in Chapter 4, but it is always desirable, when feasible, to stay as close as possible to integer values of (n) and (k ). This can often be arranged using the scaling methods for time and frequency described in Chapter 1. For example, let each (k) represent a smaller signal frequency band, say 1 kHz instead of 10 kHz, and reduce the frequency sweep range by a factor of 10. Also reduce the amplitude scale. This is what a spectrum analyzer does, and Fig. 3-1d is an example of how this works (see Fig. 3-2). One common problem with leakage is that it can obscure spectrum amplitudes on closely adjacent frequencies, making frequency resolution uncertain. For example, in Fig. 3-1c and d the very small slope at the spectrum peak (38.0) makes it difÞcult to distinguish closely adjacent frequencies. Zooming in on the peak, both horizontally and vertically, can be helpful but there is always some uncertainty about the true frequency. A familiar example of this problem is the ordinary digital frequency counter. No matter how many digits are displayed, the uncertainty is at least ± 1 2 the least signiÞcant digit. The scaling procedure is a good way to improve this problem. At this point we bring up another example, similar to Fig. 2-1, of a common problem that occurs in sequence analysis. Figure 3-1e shows a 48 DISCRETE-SIGNAL ANALYSIS AND DESIGN sine wave with an added dc bias. The DFT (see Fig. 3-1f) shows the correct line spectrum. When we try to reconstruct the sine wave using fractional instead of integer values of time and frequency in order to improve the resolution the result is not very good (see Fig. 3-1g). The second attempt, using integer values of time x(n) and frequency X(k), is successful (see Fig. 3-1e). When we design a problem on the computer we usually have the option of specifying the exact frequency to within a very small error as shown in Fig. 3-1a. If the data is from a less exact source, we may be able to assign an exact frequency that is equal to 2 M (M =integer) using the scaling methods in Chapter 1. If the computer program is trying to determine the true frequency, the problem is the same as the frequency counter problem. However, phase noise (related to frequency jitter) and other random or pseudo random problems can often be improved by using statistical methods such as record averaging, which will be described in later chapters. It is also possible to insert experimentally a small frequency offset into the problem that puts a deep notch at some integer frequency, as shown in the following Example (3-1). Finally, Chapter 4 discusses the subject of windowing, which can relax somewhat the requirements for close alignment with integer values of (n) and (k ). Example 3-1: Frequency Scaling to Reduce Leakage Frequency scaling can improve spectral leakage. Figure 3-2 illustrates how two signals on adjacent frequencies (24 and 25) interact when their frequency values are not aligned with integer-valued frequencies. Two values of percentage frequency offset are shown, 1.0% (24.24 and 25.25) and 0.1% (24.024 and 25.025). The improvement in dB isolation between the two can be signiÞcant in many applications. ALIASING IN THE FREQUENCY DOMAIN This is another important subject that occurs very often and requires care- ful attention. Figure 3-3 shows the amplitude of a discrete two-sided com- plex phasor spectrum that is centered at zero with frequency range −16 to +16. For a steady-state inÞnite sequence, duplicate two-sided spectra SPECTRAL LEAKAGE AND ALIASING 49 −50 −40 −30 −20 −10 0 40 30 20 10 0 1.0% frequency offset 0.1% frequency offset dB 20 21 22 23 24 25 26 27 28 29 3 0 k 20 21 22 23 24 25 26 27 28 29 k 30 Z(k) : = ZZ(k) : = 20 ⋅ log (|Z(k)|) ∑ N−1 n = 0 1 N n N j⋅2⋅p⋅ ⋅(k1 − k)exp ⋅ X(k) : = XX(k) : = 20 ⋅ log(|X(k)|) ∑ N−1 n = 0 1 N n N j⋅2⋅p⋅ ⋅(k0 − k)exp ⋅ Figure 3-2 Spectral leakage versus frequency offset. are centered at, ±32, ±64, and so on. We see that the two phasor spectra overlap considerably at ±16, and also at 0 and ±32 to a lesser extent. Figure 3-3 is a set of discrete-frequency Fourier transformations of an eternal steady-state discrete-time process. Each line is the amplitude X (k) of a rotating phasor at frequency (k ) (review Fig. 1-5). The discrete phasor 50 DISCRETE-SIGNAL ANALYSIS AND DESIGN 0 −16 +16 −32 +32 NEG FREQPOS FREQ NEG FREQPOS FREQ Figure 3-3 Phasor aliasing in the frequency domain. spectrum is a collection of these individual rotating phasors. The value at each (k) is determined by the (0 ≤ n ≤ N − 1) indicated in Eq. (1-2). Also indicated at k =0 is a dc value. There are two common explanations for this overlap at k =0. One is that they are created by conditions that exist in the x(n) time-domain sequence for values of n<0. This is time-domain aliasing, which is discussed at greater length later in this chapter. These values of x(n) can often transform into values of X (k) that are in the phasor negative- frequency range. For example, a capacitor or inductor that has a changing energy storage before n =0 can lead to this overlap from k < 0tok =0to k > 0. This situation also replicates at ±32, ±64 and so on. These (n < 0) conditions are parts of the eternal x(n) sequence that repeats over and over in time and therefore also in frequency. If the value of X(k )atk =0 is not zero, there is a permanent dc component in the spectrum. The entire patterns of x (n)andX(k) repeat endlessly. The second explanation is considered next. When a phasor spectrum is created by frequency translation from radio (RF) or intermediate (IF) frequencies to baseband, phasors that overlap into negative frequencies can be created. We will learn how to deal with this problem. The overlap condition illustrated in Fig. 3-3 is aliasing, meaning that parts of one spectrum segment invade its two neighbors and become associated, often inextricably, with them. At 0, ±16, and ±32, etc., a negative-frequency phasor region collides with a positive-frequency pha- sor region. Note that the spectra in Fig. 3-3 are symmetrical with respect to 0, ± 16, and ±32, but very often they are not symmetrical, as illustrated in Fig. 1-3. The overlap regions produce interactions between the two spectra that can be very difÞcult to deal with and to separate. Because the phase relationships in the overlapping negative- and positive-frequency . example, similar to Fig. 2-1, of a common problem that occurs in sequence analysis. Figure 3-1e shows a 48 DISCRETE-SIGNAL ANALYSIS AND DESIGN sine wave with an added dc bias. The DFT (see Fig. 3-1f). calculates and then sums, for each SPECTRAL LEAKAGE AND ALIASING 47 of 128 time values in Fig. 3-1c, the magnitude of X(k)indBbelowthe reference level (0 dB). Note that the loop width at 38 is 2.0 and. 37 and 39. If we calculate the real and imaginary parts of the spectrum, we could have a vector network analyzer. In other words, the Mathcad Worksheet can be taught how to measure forward and