M. J. Roberts - 8/17/04 Chapter 7 - Sampling and the DFT Selected Solutions (In this solution manual, the symbol, ⊗, is used for periodic convolution because the preferred symbol which appears in the text is not in the font selection of the word processor used to create this manual.) 1. Sample the signal, x( t) = 10 sinc(500 t) by multiplying it by the pulse train p( t) = rect (10 4 t) ∗ 1000 comb(1000 t) to form the signal, x p ( t) . Sketch the magnitude of the CTFT, X p ( f ) , of x p ( t) . 1 ∞ k f − 1000 k Xp( f ) = sinc rect ∑ 10 500 500 k =−∞ 2. Let x( t) = 10 sinc(500 t) as in Exercise 1 and form a signal, x p ( t) = [1000 x( t) comb(1000 t)] ∗ rect (10 4 t) . Sketch the magnitude of the CTFT, X p ( f ) , of x p ( t) and compare it to the result of Exercise 1. Xp( f ) = ∞ 1 f f − 1000 k sinc 4 ∑ rect 10 k =−∞ 500 500 3. Given a CT signal, x( t) = tri(100 t) , form a DT signal, x[ n ] , by sampling x( t) at a rate, f s = 800, and form an information-equivalent CT impulse signal, xδ ( t) , by multiplying x( t) by a periodic sequence of unit impulses whose fundamental frequency is the same, f 0 = f s = 800 . Sketch the magnitude of the DTFT of x[ n ] and the CTFT of xδ ( t) . Change the sampling rate to f s = 5000 and repeat. x[ n ] = tri(100 nTs ) Solutions 7-1 M. J. Roberts - 8/17/04 fs f F sinc 2 s ∗ comb ( F ) 100 100 f ∞ f − kf s Xδ ( f ) = s ∑ sinc 2 100 100 k =−∞ X(F ) = 4. Given a bandlimited CT signal, t x( t) = sinc cos(2πt) , 4 form a DT signal, x[ n ] , by sampling x( t) at a rate, f s = 4, and form an information-equivalent CT impulse signal, xδ ( t) , by multiplying x( t) by a periodic sequence of unit impulses whose fundamental frequency is the same, f 0 = f s = 4 . Sketch the magnitude of the DTFT of x[ n ] and the CTFT of xδ ( t) . Change the sampling rate to f s = 2 and repeat. Similar to Exercise 3. 5. Find the Nyquist rates for these signals. (a) x( t) = sinc(20 t) X( f ) = 1 f rect ⇒ f Nyq = 2 f m = 20 20 20 (b) x( t) = 4 sinc 2 (100 t) X( f ) = 4 f tri ⇒ f Nyq = 2 f m = 200 100 100 (c) x( t) = 8 sin(50πt) X( f ) = j 4[δ ( f + 25) − δ ( f − 25)] ⇒ f Nyq = 2 f m = 50 (d) x( t) = 4 sin( 30πt) + 3 cos( 70πt) (e) x( t) = rect ( 300 t) (f) x( t) = −10 sin( 40πt) cos( 300πt) Not Bandlimited. Nyquist rate is infinite. 6. Sketch these time-limited signals and find and sketch the magnitude of their CTFT’s and confirm that they are not bandlimited. (a) t x( t) = 5 rect 100 X( f ) = 500 sinc(100 f ) Solutions 7-2 M. J. Roberts - 8/17/04 x(t)| 5 -200 200 t |X( f )| 500 -0.04 0.04 (b) x( t) = 10 tri(5 t) (c) x( t) = rect ( t)[1 + cos(2πt)] (d) x( t) = rect ( t)[1 + cos(2πt)] cos(16πt) f 7. Sketch the magnitudes of these bandlimited-signal CTFT’s and find and sketch their inverse CTFT’s and confirm that they are not time limited. X( f ) = rect ( f )e − j 4 πf x( t) = sinc( t − 2) (b) X( f ) = tri(100 f )e jπf 1 t+ 1 2 x( t) = sinc 2 100 100 (c) X( f ) = δ ( f − 4 ) + δ ( f + 4 ) x( t) = 2 cos(8πt) (a) |X( f )| 1 -4 4 f x(t) 2 -1 1 t -2 Solutions 7-3 M. J. Roberts - 8/17/04 (d) X( f ) = j[δ ( f + 4 ) − δ ( f − 4 )] ∗ rect (8 f ) 8. Sample the CT signal, x( t) = sin(2πt) , at a sampling rate, f s. Then, using MATLAB, plot the interpolation between samples in the time range, −1 < t < 1, using the approximation, f x( t) ≅ 2 c fs ∑ x(nT ) sinc(2 f (t − nT )) , N s n =− N c s with these combinations of f s, f c , and N. (a) fs = 4 , fc = 2 , N = 1 x(t) 1 -1 1 t -1 (b) fs = 4 , fc = 2 , N = 2 (c) fs = 8 , fc = 4 , N = 4 (d) fs = 8 , fc = 2 , N = 4 (e) f s = 16 , f c = 8 , N = 8 (f) f s = 16 , f c = 8 , N = 16 x(t) 1 -1 1 t -1 9. For each signal and specified sampling rate, plot the original signal and an interpolation between samples of the signal using a zero-order hold, over the time range, −1 < t < 1. (The MATLAB function “stairs” could be useful here.) (a) x( t) = sin(2πt) , f s = 8 x(t) 1 -1 (b) x( t) = sin(2πt) , f s = 32 (c) x( t) = rect ( t) , f s = 8 1 t -1 (d) x( t) = tri( t) , f s = 8 Solutions 7-4 M. J. Roberts - 8/17/04 10. For each signal in Exercise 9, lowpass filter the zero-order-hold-interpolated signal with a single-pole lowpass filter whose -3 dB frequency is one-fourth of the sampling rate. x(t) 1 -1 (a) 1 t -1 11. Repeat Exercise 9 except use a first-order hold instead of a zero-order hold. x(t) 1 -1 (a) 1 t -1 12. Sample the two signals, x1 ( t) = e − t 2 and x 2 ( t) = e − t + sin(8πt) 2 in the time interval, −3 < t < 3 , at 8 Hz and demonstrate that the sample values are the same. 13. For each pair of signals below, sample at the specified rate and find the DTFT of the sampled signals. In each case, explain, by examining the DTFT’s of the two signals, why the samples are the same. (a) x1 ( t) = 4 cos(16πt) and x 2 ( t) = 4 cos( 76πt) , f s = 30 x1[ n ] = 4 cos(16πnTs ) and x 2 [ n ] = 4 cos( 76πnTs ) [ ] X1 ( F ) = 2 comb( F − 8Ts ) + comb( F + 8Ts ) Similarly, 8 8 X1 ( F ) = 2 comb F − + comb F + 30 30 38 38 X 2 ( F ) = 2 comb F − + comb F + 30 30 8 8 X 2 ( F ) = 2 comb F − − 1 + comb F + + 1 = X1 ( F ) 30 3 30 3 144 144 42444 42444 8 8 = comb F − = comb F + 30 30 Solutions 7-5 M. J. Roberts - 8/17/04 (b) x( t) = 6 sinc(8 t) and x( t) = 6 sinc(8 t) cos( 400πt) (c) x( t) = 9 cos(14πt) and x( t) = 9 cos(98πt) , f s = 100 f s = 56 , 14. For each sinusoid, find the two other sinusoids whose frequencies are nearest the frequency of the given sinusoid and which, when sampled at the specified rate, have exactly the same samples. (a) x( t) = 4 cos(8πt) , f s = 20 (b) x( t) = 4 sin(8πt) , f s = 20 4 sin( 48πt) and − 4 sin( 32πt) (c) x( t) = 2 sin(−20πt) , f s = 50 (e) π x( t) = 5 cos 30πt + , f s = 50 4 x( t) = 2 cos(−20πt) , f s = 50 (d) 15. For each DT signal, plot the original signal and the sampled signal for the specified sampling interval. 2πn (a) x[ n ] = sin , Ns = 4 24 2πn x s[ n ] = sin comb 4 [ n ] 24 x[n] 1 -24 24 n -1 xs[n] 1 -24 24 n -1 (b) x[ n ] = rect 9 [ n ] , N s = 2 (c) 2πn 2πn x[ n ] = cos cos , Ns = 2 48 8 (d) 9 x[ n ] = u[ n ] , N s = 6 10 n Solutions 7-6 M. J. Roberts - 8/17/04 16. For each signal in Exercise 15, sketch the magnitude of the DTFT of the original signal and the sampled signal. (a) 2πn x[ n ] = sin 24 X( F ) = 2πn x s[ n ] = sin comb 4 [ n ] 24 j ∞ 1 1 δ F + − k − δ F − − k ∑ 2 k =−∞ 24 24 ∞ j ∞ 1 k 1 k X s (F ) = ∑ δ F + − − ∑ δ F − − 8 k =−∞ 24 4 k =−∞ 24 4 (b) x[ n ] = rect 9 [ n ] Xs ( F ) = x s[ n ] = rect 9 [ n ] comb 2 [ n ] 1 1 19 drcl ( F,19 ) + 19 drcl F − ,19 2 2 |X(F)| 0.25 -1 1 F |X (F)| s 0.25 -1 (c) 2πn x[ n ] = cos 8 1 F , Ns = 7 17. For each DT signal, plot the original signal and the decimated signal for the specified sampling interval. Also plot the magnitudes of the DTFT’s of both signals. (a) n n x[ n ] = tri , N s = 2 x d [ n ] = tri 10 5 2 X( F ) = 10 sinc (10 F ) ∗ comb( F ) X d ( F ) = 5 sinc 2 (5 F ) ∗ comb( F ) Solutions 7-7 M. J. Roberts - 8/17/04 (b) 2πn n x[ n ] = (0.95) sin u[ n ] , N s = 2 10 (c) 2πn x[ n ] = cos 8 , Ns = 7 18. For each signal in Exercise 17, insert the specified number of zeros between samples, lowpass DT filter the signals with the specified cutoff frequency and plot the resulting signal and the magnitude of its DTFT. (a) Insert 1 zero between points. Cutoff frequency is Fc = 0.1. n n an integer x d , x s[ n ] = N s N s 0 , otherwise n n n n an integer tri , an integer tri , Ns 2 x s[ n ] = 5 N s = 10 0 0 , otherwise , otherwise n x s[ n ] = tri comb 2 [ n ] 10 Using n F tri ← → w sinc 2 ( wF ) ∗ comb ( F ) w [ ] X s ( F ) = 10 sinc 2 (10 F ) ∗ comb( F ) ⊗ comb(2 F ) 1 1 X s ( F ) = 10 sinc 2 (10 F ) ∗ comb( F ) ∗ δ ( F ) + δ F − 2 2 [ ] 1 X s ( F ) = 5 sinc 2 (10 F ) ∗ comb( F ) + comb F − 2 ∞ 1 X s ( F ) = 5 ∑ sinc 2 (10( F − k )) + sinc 2 10 F − − k 2 k =−∞ 1 X i ( F ) = [rect (5 F ) ∗ comb( F )] × 5 sinc 2 (10 F ) ∗ comb( F ) + comb F − 2 Solutions 7-8 M. J. Roberts - 8/17/04 ∞ 1 X i ( F ) = [rect (5 F ) ∗ comb( F )] × 5 ∑ sinc 2 (10( F − k )) + sinc 2 10 F − − k 2 k =−∞ n F F Using x [ n ] ∗ y [ n ] ← → X ( F ) Y ( F ) , tri ← → w sinc 2 ( wF ) ∗ comb ( F ) w F and e j 2 π F0 n x [ n ] ← → X ( F − F0 ) n 1 n 1 n x i [ n ] = sinc ∗ tri + tri e jπn 5 10 10 10 10 πn πn πn j n 1 n n 1 n j 2 − j 2 jπn 1 x i [ n ] = sinc ∗ tri ( + e ) = sinc ∗ tri e e +e 2 5 10 10 5 10 10 πn 1 n n j πn x i [ n ] = sinc ∗ tri e 2 cos 5 10 2 5 xi[n] = πm 1 ∞ m j 2 πm n − m tri e cos sinc ∑ 2 5 5 m =−∞ 10 xi[n] 0.5 -20 20 n |Xi(F)| 5 -1 1 (b) Insert 4 zeros between points. Cutoff frequency is Fc = 0.2 . (c) Insert 4 zeros between points. Cutoff frequency is Fc = 0.02 . F 19. Sample the following CT signals, x( t) , to form DT signals, x[ n ] . Sample at the Nyquist rate and then at the next higher rate for which the number of samples per cycle is an integer. Plot the CT and DT signals and the magnitudes of the CTFT’s of the CT signals and the DTFT’s of the DT signals. (a) x( t) = 2 sin( 30πt) + 5 cos(18πt) Solutions 7-9 M. J. Roberts - 8/17/04 [ ] 52 [δ ( f + 9) + δ ( f − 9)] X( f ) = j δ ( f + 15) − δ ( f − 15) + Nyquist rate is 30 Hz. Period is 1 second. Ten samples are required. 3 At Nyquist rate: 3πn x Nyq [ n ] = 2 sin( 30πnTs ) + 5 cos(18πnTs ) = 2 sin(πn ) + 5 cos 5 1 1 5 3 3 X Nyq ( F ) = j comb F + − comb F − + comb F − + comb F + 2 2 2 10 10 144444 42444444 3 = 0 due to aliasing X Nyq ( F ) = 5 3 3 comb F − + comb F + 2 10 10 At the next higher rate 11 samples are required and the sampling rate is 33 Hz. 10πn 6πn x11[ n ] = 2 sin( 30πnTs ) + 5 cos(18πnTs ) = 2 sin + 5 cos 11 11 5 5 5 3 3 X11 ( F ) = j comb F + − comb F − + comb F − + comb F + 11 11 2 11 11 x(t) |X(f )| 8 -0.25 3 0.25 t -8 -15 xNyq[n] 15 5 -8 3 8 n -5 -1 x [n] 1 11 5 3 8 -5 (b) F |X (F )| 11 -8 f |XNyq(F )| n -1 1 F x( t) = 6 sin(6πt) cos(24πt) N 20. For each of these signals find the DTFS over one period and show that X 0 is real. 2 (a) x[ n ] = rect 2 [ n ] ∗ comb12 [ n ] FS Using rect Nw [ n ] ∗ comb N0 [ n ] ← → ( 2 N w + 1) drcl N0 Solutions 7-10 k N , ( 2 N w + 1) o M. J. Roberts - 8/17/04 X[ k ] = 5 k drcl , 5 12 12 X[6] = X[ k ] = 5 6 drcl , 5 12 12 (b) x[ n ] = rect 2 [ n + 1] ∗ comb12 [ n ] (c) 14πn 2πn x[ n ] = cos cos 16 16 5π sin 2 1 1 = = , 12 π 12 sin 2 (d) Real. 2π ( n − 3) 12πn x[ n ] = cos cos 14 14 21. Start with a signal, x( t) = 8 cos( 30πt) , and sample, window and periodically-repeat it using a sampling rate of f s = 60 and a window width of N F = 32. For each signal in the process, plot the signal and its transform, either CTFT or DTFT. F x ( t ) = 8 cos ( 30π t ) ← → X ( f ) = 4 δ ( f − 15 ) + δ ( f + 15 ) 2π n F x s [ n ] = 8 cos ←→ X s ( F ) = 4 comb F − 4 1 + comb F + 4 1 4 2πn , 0 ≤ n < 32 8 cos 4 x sw [ n ] = 0 , otherwise 1 1 1 sin 32π F + − j 31π F − 1 sin 32π F − − j 31π F + 4 4 4 4 X sw ( F ) = 4 e +e 1 1 sinπ F − sinπ F + 4 4 2π n F x sws [ n ] = 8 cos ←→ X sws [ k ] = 4 ( comb 32 [ k − 8 ] + comb 32 [ k + 8 ]) 4 ∞ k X( F ) = 4 ∑ (comb 32 [ k − 8] + comb 32 [ k + 8])δ F − 32 k =−∞ Solutions 7-11 M. J. Roberts - 8/17/04 |Xsws(F )| xsws[n] 4 8 -1 -16 48 n Phase of Xsws(F ) 1 F 1 F π -1 -8 -π 22. Sometimes window shapes other than a rectangle are used. Using MATLAB, find and plot the magnitudes of the DFT’s of these window functions, with N = 32. (a) von Hann or Hanning w[ n ] = 1 2πn 1 − cos , 0≤ n< N N − 1 2 x[n] |X[k]| 1 16 31 (b) n -32 32 k Bartlett N −1 2n ≤ ≤ n , 0 N − 1 2 w[ n ] = n N 2 − 1 2 − , ≤n<N N −1 2 (c) Hamming (d) Blackman 2πn w[ n ] = 0.54 − 0.46 cos , 0≤ n< N N − 1 2πn 4πn w[ n ] = 0.42 − 0.5 cos + 0.08 cos , 0≤ n< N N − 1 N − 1 23. Sample the following signals at the specified rates for the specified times and plot the N N magnitudes of the DFT’s versus harmonic number in the range, − F < k < F − 1. 2 2 (a) x( t) = cos(2πt) , f s = 2 , N F = 16 Solutions 7-12 M. J. Roberts - 8/17/04 x[n] |X[k]| 1 16 15 n -1 -8 (b) x( t) = cos(2πt) , fs = 8 (c) x( t) = cos(2πt) , f s = 16 (d) x( t) = cos( 3πt) , fs = 2 , N F = 16 (e) x( t) = cos( 3πt) , fs = 8 , N F = 16 (f) x( t) = cos( 3πt) , f s = 16 24. Sample the magnitudes N − F <k< 2 k 7 N F = 16 , N F = 256 , N F = 256 , following signals at the specified rates for the specified times and plot the and phases of the DFT’s versus harmonic number in the range, NF − 1. 2 (a) x( t) = tri( t − 1) , fs = 2 , N F = 16 (b) x( t) = tri( t − 1) , fs = 8 , N F = 16 (c) x( t) = tri( t − 1) , f s = 16 , N F = 256 f = 16 , N = 256 s F |X[k]| 16 -128 127 k Phase of X[k] π -128 127 -π (d) x( t) = tri( t) + tri( t − 4 ) , fs = 2 , NF = 8 (e) x( t) = tri( t) + tri( t − 4 ) , fs = 8 , N F = 32 Solutions 7-13 k M. J. Roberts - 8/17/04 (f) x( t) = tri( t) + tri( t − 4 ) f s = 64 , , N F = 256 25. Sample each CT signal, x( t) , N F times at the rate, f s, creating the DT signal, x[ n ] . Plot x( t) vs. t and x[ n ] vs. nTs over the time range, 0 < t < N F Ts. Find the DFT, X[ k ], of the N F samples. Then plot the magnitude and phase of X( f ) vs. f and Ts X[ k ] vs. k∆f over the f f f frequency range, − s < f < s , where ∆f = s . Plot Ts X[ k ] as a continuous function of NF 2 2 k∆f using the MATLAB “plot” command. (a) x( t) = 5 rect (2( t − 2)) f s = 16 , N F = 64 , 5 f X( f ) = sinc e − j 4 πf 2 2 |X( f )| x(t) 2.5 5 -8 8 f 8 f 8 kfs/NF 8 kfs/NF Phase of X( f ) π 4 t -8 -π |TsX[k]| 2.5 x[n] 5 -8 Phase of TsX[k] π 4 nTs (b) t − 20 x( t) = 3 sinc 5 (c) x( t) = 2 rect ( t − 2) sin(8πt) (d) t − 2 t − 6 x( t) = 10 tri − tri 2 2 (e) x( t) = 5 cos(2πt) cos(16πt) , -8 -π fs = 1 , , , N F = 40 f s = 32 , , fs = 8 f s = 64 , N F = 128 , N F = 64 N F = 128 26. Sample each CT signal, x( t) , N F times at the rate, f s, creating the DT signal, x[ n ] . Plot x( t) vs. t and x[ n ] vs. nTs over the time range, 0 < t < N F Ts. Find the DFT, X[ k ], of the N F X[ k ] samples. Then plot the magnitude and phase of X( f ) vs. f and vs. k∆f over the NF Solutions 7-14 M. J. Roberts - 8/17/04 fs f f X[ k ] < f < s , where ∆f = s . Plot as an impulse function of k∆f NF NF 2 2 using the MATLAB “stem” command to represent the impulses. frequency range, − (a) x( t) = 4 cos(200πt) (b) x( t) = 6 rect (2 t ) ∗ comb( t) f s = 800 , , N F = 32 , f s = 16 N F = 128 , ∞ f k X( f ) = 3 sinc comb( f ) = 3 ∑ sinc δ ( f − k ) 2 2 k =−∞ |X( f )| x(t) 3 6 -8 8 f 8 f 8 kfs/NF 8 kfs/NF Phase of X( f )| π 8 t -8 -π |X[k]/NF| 3 x[n] 6 -8 Phase of X[k]/NF π 8 -8 nTs (c) x( t) = 6 sinc( 4 t ) ∗ comb( t) (d) x( t) = 5 cos(2πt) cos(16πt) , , -π f s = 16 , N F = 128 f s = 64 , N F = 128 27. Using MATLAB (or an equivalent mathematical computer tool) plot the signal, x(t ) = 3 cos(20πt ) − 2 sin(30πt ) over a time range of 0 < t < 400 ms . Also plot samples of this function taken at the following 1 1 1 1 s , b) Ts = sampling intervals: a) Ts = s, c) Ts = s and d) Ts = s. Based on what 120 60 30 15 you observe what can you say about how fast this signal should be sampled so that it could be reconstructed from the samples? 28. A signal, x(t ) = 20 cos(1000πt ) is impulse sampled at a sampling rate of 2 kHz. Plot two periods of the impulse-sampled signal, xδ ( t) . (Let the one sample be at time, t = 0.) Then plot four periods, centered at zero Hz, of the CTFT, X n ( f ) , of the impulse-sampled signal, xδ ( t) . Change the sampling rate to 500 Hz and repeat. Solutions 7-15 M. J. Roberts - 8/17/04 t A signal, x(t ) = 10 rect , is impulse sampled at a sampling rate of 2 Hz. Plot the 4 impulse-sampled signal, xδ ( t) on the interval, −4 < t < 4 . Then plot three periods, centered at f = 0 , of the CTFT, Xδ ( f ) , of the impulse-sampled signal, xδ ( t) . Change the sampling rate to 1/2 Hz and repeat. 29. fs = 2 Hz xδ(t) fs =1/ 2 Hz xδ(t) 10 10 -8 t 8 -2 |Xδ( f )| 2 t |Xδ( f )| 80 20 -5 5 f -2 Phase of Xδ( f 2 f Phase of Xδ( f ) π π -5 5 f -π -2 2 f -π 30. A signal, x(t ) = 4 sinc(10t ) , is impulse sampled at a sampling rate of 20 Hz. Plot the impulse-sampled signal, xδ ( t) on the interval, -0.5 < t < 0.5. Then plot three periods, centered at f = 0 , of the CTFT, Xδ ( f ) , of the impulse-sampled signal, xδ ( t) . Change the sampling rate to 4 Hz and repeat. A DT signal, x[ n ] , is formed by sampling a CT signal, x( t) = 20 cos(8πt) , at a sampling rate of 20 Hz. Plot x[ n ] over 10 periods versus discrete time. Then do the same for sampling frequencies of 8 Hz and 6 Hz. 31. 32. A DT signal, x[ n ] , is formed by sampling a CT signal, x(t ) = −4 sin(200πt ) , at a sampling rate of 400 Hz. Plot x[ n ] over 10 periods versus discrete time. Then do the same for sampling frequencies of 200 Hz and 60 Hz. 33. Find the Nyquist rates for these signals. (a) x( t) = 15 rect ( 300 t) cos(10 4 πt) (b) x( t) = 7 sinc( 40 t) cos(150πt) X( f ) = 7 f 1 rect ∗ δ ( f − 75) + δ ( f + 75) 40 2 40 X( f ) = 7 f + 75 f − 75 rect ⇒ f Nyq = 2 f m = 190 + rect 40 40 80 [ ] Solutions 7-16 M. J. Roberts - 8/17/04 (c) x( t) = 15[rect (500 t) ∗ 100 comb(100 t)] cos(10 4 πt) Not Bandlimited. Nyquist rate is infinite. (d) x( t) = 4[sinc(500 t) ∗ comb(200 t)] (e) x( t) = −2[sinc(500 t) ∗ comb(200 t)] cos(10 4 πt) 34. On one graph, plot the DT signal formed by sampling the following three CT functions at a sampling rate of 30 Hz. (a) x1 (t ) = 4 sin(20πt ) x 2 (t ) = 4 sin(80πt ) (b) x 2 (t ) = −4 sin( 40πt ) (c) 35. Plot the DT signal, x[ n ] , formed by sampling the CT signal, x(t ) = 10 sin(8πt ) , at twice the Nyquist rate and x( t) itself. Then on the same graph plot at least two other CT sinusoids which would yield exactly the same samples if sampled at the same times. fs = 16 x[n] 10 8 n -10 36. Plot the magnitude of the CTFT of t x(t ) = 25 sinc 2 . 6 What is the minimum sampling rate required to exactly reconstruct x(t) from its samples? Infinitely many samples would be required to exactly reconstruct x(t) from its samples. If one were to make a practical compromise in which he sampled over the minimum possible time which could contain 99% of the energy of this waveform, how many samples would be required? Solutions 7-17 M. J. Roberts - 8/17/04 (25sinc2(t/6))2 600 10 t X( f ) = 150 tri(6 f ) The maximum frequency present in s(t) occurs where 6 f = ±1 or f = ± 1 . 6 The total energy is most easily found in the frequency domain, ∞ EX = ∫ X( f ) 2 ∞ df = −∞ 1 6 ∫ 150 tri(6 f ) −∞ 2 1 6 df = 150 2 ∫ tri(6 f ) df − 2 1 6 1 6 1 6 E X = 150 2 × 2 ∫ tri(6 f ) df = 150 2 × 2 ∫ (1 − 6 f ) df = 150 2 × 2 ∫ (1 − 12 f + 36 f 2 ) df 2 2 [ E X = 150 2 × 2 f − 6 f 2 + 12 f 0 0 0 ] 1 3 6 0 12 1 6 12 = 150 2 × 2 − + = 150 2 × 2 = 2500 6 36 216 216 From MATLAB simulation and trapezoidal-rule integration the minimum possible time that would contain 99% of the energy of the signal would be from -3.9 s to +3.9 s. Sample at times, -3 s, 0 s and 3 s. 37. Plot the magnitude of the CTFT of x(t ) = 8 rect(3t ) . This signal is not bandlimited so it cannot be sampled adequately to exactly reconstruct the signal from the samples. As a practical compromise, assume that a bandwidth which contains 99% of the energy of x(t) is great enough to practically reconstruct x(t) from its samples. What is the minimum required sampling rate in this case? Solutions 7-18 M. J. Roberts - 8/17/04 |X( f )|2 7 8 f 8 f X( f ) = sinc 3 3 The total signal energy can be found most simply in the time domain. ∞ Ex = ∫ x(t) −∞ 2 ∞ dt = ∫ 8 rect (3t) −∞ 2 1 6 dt = 64 ∫ dt = − 1 6 64 3 From MATLAB simulation and trapezoidal-rule integration the minimum possible frequency range that would contain 99% of the energy of the signal would be from -30.9 Hz to +30.9 Hz. totalArea=64/3 ; %From analytical solution in time domain. ptsPerLobe=40 ; df=3/ptsPerLobe ; %First zero at 3 Hz, 20 pts per lobe. nLobes=4 ; nPts=ptsPerLobe*nLobes ; f=[0:df:nPts*df] ; X=abs((8/3)*sinc(f/3)).^2 ; p1=plot(f,S,'k') ; grid ; set(p1,'LineWidth',2) ; title('Problem 9.3.11','FontName','Times','FontSize',18) ; xlabel('Frequency, f (Hz)','FontName','Times') ; ylabel('|(8/3)*sinc(f/3)|^2','FontName','Times') ; set(gca,'Position',[0.1,0.6,0.6,0.3],'FontName','Times') ; loop='y' ; area=0 ; f1=0 ; f2=df ; while loop=='y', area=area+(abs(8/3)^2)*(sinc(f1/3)^2+sinc(f2/3)^2)*df/2 ; disp(['f2 = ',num2str(f2),', Area = ',num2str(area)]) ; if area>.99*totalArea/2, loop='n' ; else f1=f1+df ; f2=f2+df ; end end 38. A signal, x( t) , is periodic and one period of the signal is described by 3t , 0 < t < 5.5 . x( t ) = 0 , 5.5 < t < 8 Solutions 7-19 M. J. Roberts - 8/17/04 Find the samples of this signal over one period sampled at a rate of 1 Hz (beginning at time, t = 0). Then plot, on the same scale, two periods of the original signal and two periods of a periodic signal which is bandlimited to 0.5 Hz or less that would have these same samples. x(0) = 0 , x(1) = 3 , x(2) = 6 , x(3) = 9 , x( 4) = 12 , x(5) = 15 , x(6) = 0 , x(7) = 0 Using MATLAB, 45.0000 , − 26.8492 + j3.8787 , 6.0000 + j9.0000 , 2.8492 − j8.1213 , X= −9.0000 , 2.8492 + j8.1213 , 6.0000 − j9.0000 , − 26.8492 − 3.8787i x(t), x (t) and x[n] bl 20 16 % t Solution to Exercise 38 in Sampling and the DFT close all ; fs = 1 ; Ts = 1/fs ; T = 8 ; N = T/Ts ; % Set up a vector of sampling times, ts. ts = [0:Ts:(N-1)*Ts]' ; % Set up a vector of corresponding sample values, xs. xs = 3*ramp(ts).*rect((ts-2.75)/5.5) ; % % Set up vectors of times and signal values much closer for plotting the continuous signal, x. nPts = 256 ; dt = T/nPts ; t = [0:dt:(nPts-1)*dt]' ; x = 3*ramp(t).*rect((t-2.75)/5.5) ; % Find the CTFS of the signal, x(t). [Xs,k] = CTFS(xs,ts,k) ; % % % Generate the bandlimited signal, xbl, which passes through all the samples, xs[n]. Sum all the complex frequency components from n = -N/2 to n = +N/2. Solutions 7-20 M. J. Roberts - 8/17/04 xbl = zeros(nPts,1) ; f0 = 1/T ; for nn = -N/2:N/2-1, xbl = xbl + Xs(nn+N/2+1)*exp(j*2*nn*pi*f0*t) ; end % % Clean up any small imaginary parts left over due to round off error. xbl=real(xbl) ; % % Form two periods from the one period computed so far for each time-domain function computed; s, x and sbl. xbl2 = [xbl;xbl] ; t2 = [t;t+T] ; x2 = [x;x] ; xs2 = [xs;xs] ; ts2 = [ts;ts+T] ; % Plot the original signal, samples and bandlimited signal. p = xyplot({t2,t2,ts2},{x2,xbl2,xs2},[0,16,0,20],'\itt',... 'x({\itt}),x_b_l({\itt}) and x[{\itn}]','Times',18,'Times',14,... '','Times',24,{'n','n','n'},{'c','c','d'},{'k','k','k'}) ; set(p{1},'LineWidth',0.5) ; 39. How many sample values are required to yield enough information to exactly describe these bandlimited periodic signals? (a) x(t ) = 8 + 3 cos(8πt ) + 9 sin( 4πt ) , f m = 4, f Nyq = 8 T0 = least common multiple of 1 1 1 s and s which is s. 2 4 2 At the Nyquist rate we would have 4 samples. We must have an integer number of samples in one period, sampled above the Nyquist rate therefore we need 5 samples and f s = 10. (b) x(t ) = 8 + 3 cos(7πt ) + 9 sin( 4πt ) 40. Sample the CT signal, 1 t x( t) = 15 sinc(5 t) ∗ comb sin( 32πt) 2 2 to form the DT signal, x[ n ] . Sample at the Nyquist rate and then at the next higher rate for which the number of samples per cycle is an integer. Plot the CT and DT signals and the magnitude of the CTFT of the CT signal and the DTFT of the DT signal. x( t) = 15 sin( 32πt) X( f ) = j ∞ ∑ sinc(5(t − 2m)) m =−∞ 3 5 k rect δ f + 16 − ∑ 10 4 k =−5 k − δ f − 16 − 2 Solutions 7-21 k 2 M. J. Roberts - 8/17/04 The highest frequency in the signal is 18.5 Hz. Therefore, the Nyquist rate is 37 Hz. The period is 2. Therefore 74 samples are required. 3 5 16 k 16 k k X( F ) = j ∑ rect δ F + − − δ F − − ∗ comb( F ) 10 4 k =−5 37 74 37 74 1 relative to integer values (which occur when k = ±5), cancel each other 2 out leaving only the ones above and below. The impulses at F = ± At the next higher sampling rate 75 samples are required in 2 seconds. Therefore the sampling rate is 37.5 Hz and 3 5 32 k 32 k k X( F ) = j ∑ rect δ F + − − δ F − − ∗ comb( F ) 10 4 k =−5 75 75 75 75 41. Without using a computer, find the forward DFT of the following sequence of data and then find the inverse DFT of that sequence and verify that you get back the original sequence. {x[0],x[1],x[2],x[3]} = {3, 4 ,1,− 2} X[ k ] = N 0 −1 ∑ x[n]e −j n =0 3 3 n =0 n =0 X[0] = ∑ x[ n ] = 3 + 4 + 1 − 2 = 6 , X[1] = ∑ x[ n ]e 3 X[2] = ∑ x[ n ]e n =0 − jπn 2πnk N 3 −j πn 2 = 3 − j 4 − 1 − j2 = 2 − j6 = 3 − 4 + 1 + 2 = 2 , X[ 3] = ∑ x[ n ]e −j 3πn 2 = 3 + j 4 − 1 + j2 = 2 + j6 n =0 42. Redo Example 7-5 except with x(t ) = 1 + sin(8πt ) + cos( 4πt ) as the signal being sampled. Explain any apparent discrepancies that arise. 43. Sample the bandlimited periodic signal, x(t ) = 15 cos(300πt ) + 40 sin(200πt ) at exactly its Nyquist rate over exactly one period of x( t) . Find the DFT of those samples. From the DFT find the CTFS. Plot the CTFS representation of the signal that results and compare it with x(t). Explain any differences. Repeat for a sampling rate of twice the Nyquist rate. Solutions 7-22 M. J. Roberts - 8/17/04 x(t) and x[n] 50 t 0.02 -50 x(t) from CTFS 50 t 0.02 -50 x(t) and x[n] 50 0.02 t -50 x(t) from CTFS 50 0.02 t -50 44. Sample the bandlimited periodic signal, x(t ) = 8 cos(50πt ) − 12 sin(80πt ) at exactly its Nyquist rate over exactly one period of x(t). Find the DFT of those samples. From the DFT find the CTFS. Plot the CTFS representation of the signal that results and compare it with x(t). Explain any differences. Repeat for a sampling rate of twice the Nyquist rate. x(t) and x[n] 20 0.2 t -20 x(t) from CTFS 20 0.2 t -20 x(t) and x[n] 20 0.2 t -20 x(t) from CTFS 20 0.2 t -20 45. Using MATLAB, (a) Generate a pseudo-random sequence of 256 data points in a vector, "x", using the "randn" function which is built in to MATLAB. Solutions 7-23 M. J. Roberts - 8/17/04 (b) Find the DFT of that sequence of data and put it in a vector, "X". (c) Set a vector, "Xlpf", equal to "X". (d) Change all the values in "Xlpf" to zero except the first 8 points and the last 8 points. (e) Take the real part of the inverse DFT of "Xlpf" and put it in a vector, "xlpf". (f) Generate a set of 256 sample times, "t", which begin with "0" and are uniformly separated by "1". (g) Plot "x" and "xlpf" versus "t" on the same scale and compare. What kind of effect does this operation have on a set of data? Why is the output array called "xlpf"? x(t) and x (t) lpf 3 256 t -3 % Solution to exercise 45 in Sampling and the DFT close all ; x = randn(256,1) ; X = fft(x) ; mask = [ones(8,1);zeros(240,1);ones(8,1)] ; Xlpf = mask.*X ; xlpf = real(ifft(Xlpf)) ; t = [0:255]' ; p = xyplot({t,t},{x,xlpf},[0,256,-3,3],'\itt',... 'x({\itt}) and x_l_p_f({\itt})','Times',18,... 'Times',14,'','Times',24,{'n','n'},{'c','c'},{'k','k'}) ; set(p{1},'LineWidth',0.5) ; 46. Sample the signal, x( t) = rect ( t) , at three different frequencies, 8 Hz, 16 Hz and 32 Hz for 2 seconds. Plot the magnitude of the DFT in each case. Which of these sampling frequencies yields a magnitude plot that looks most like the magnitude of the CTFT of x(t)? 47. Sample the signal, x(t ) = rect(t ) , at 8 Hz for three different total times, 2 seconds, 4 seconds and 8 seconds. Plot the magnitude of the DFT in each case. Which of these total sampling times yields a magnitude plot that looks most like the magnitude of the CTFT of x(t)? Solutions 7-24 M. J. Roberts - 8/17/04 48. Sample the signal, x(t ) = cos(πt ) at three different frequencies, 2 Hz, 4 Hz and 8 Hz for 5 seconds. Plot the magnitude of the DFT in each case. Which of these sampling frequencies yields a magnitude plot that looks most like the magnitude of the CTFT of x(t)? 49. Sample the signal, x(t ) = cos(πt ) , at 8 Hz for three different total times, 5 seconds, 9 seconds and 13 seconds. Plot the magnitude of the DFT in each case. Which of these total sampling times yields a magnitude plot that looks most like the magnitude of the CTFT of x(t)? Solutions 7-25