




























































































Studirajte zahvaljujući brojnim resursima koji su dostupni na Docsity-u
Zaradite bodove pomažući drugim studentima ili ih kupite uz Premium plan
Ova stranica nije vidljiva u pregledu
Ne propustite važne delove!





























































































AMSTERDAM • BOSTON • HEIDELBERG • LONDON NEW YORK •^ OXFORD •^ PARIS •^ SAN DIEGO SAN FRANCISCO •^ SINGAPORE •^ SYDNEY •^ TOKYO Academic Press is an imprint of Elsevier
This page intentionally left blank
CHAPTER 7
Sampling Theory
The pure and simple truth is rarely pure and never simple. Oscar Wilde (1854–1900) Irish writer and poet
7.1 INTRODUCTION
Since many of the signals found in applications such as communications and control are analog, if we wish to process these signals with a computer it is necessary to sample, quantize, and code them to obtain digital signals. Once the analog signal is sampled in time, the amplitude of the obtained discrete-time signal is quantized and coded to give a binary sequence that can be either stored or processed with a computer.
The main issues considered in this chapter are:
n How to sample—As we will see, it is the inverse relation between time and frequency that provides the solution to the problem of preserving the information of an analog signal when it is sampled. When sampling an analog signal one could choose an extremely small value for the sampling period so that there is no significant difference between the analog and the discrete signals— visually as well as from the information content point of view. Such a representation would, however, give redundant values that could be spared without losing the information provided by the analog signal. If, on the other hand, we choose a large value for the sampling period, we achieve data compression but at the risk of losing some of the information provided by the analog signal. So how do we choose an appropriate value for the sampling period? The answer is not clear in the time domain. It does become clear when considering the effects of sampling in the frequency domain: The sampling period depends on the maximum frequency present in the analog signal. Furthermore, when using the correct sampling period the information in the analog signal will remain in the discrete signal after sampling, thus allowing the reconstruction of the original signal from the samples. These results, introduced by Nyquist and Shannon, constitute
Signals and Systems Using MATLAB ®. DOI: 10.1016/B978-0-12-374716-7.00011- © c 2011, Elsevier Inc. All rights reserved. 419
7.2 Uniform Sampling 421
and its Fourier transform is XPAM() =
k
PkX( − k 0 )
showing that PAM is a modulation of the train of pulses p(t) by the signal x(t). The spectrum of xPAM(t) is the spectrum of x(t) shifted in frequency by {k 0 }, weighted by Pk, and superposed.
Given that the pulse width 1 is much smaller than Ts, p(t) can be replaced by a periodic sequence of impulses of period Ts (see Figure 7.1) or δTs (t). This simplifies considerably the analysis and makes the results easier to grasp. Later in the chapter we consider the effects of having pulses instead of impulses, a more realistic assumption.
The sampling function δTs (t), or a periodic sequence of impulses of period Ts, is
δTs (t) =
n
δ(t − nTs) (7.3)
where δ(t − nTs) is an approximation of the normalized pulse [u(t − nTs) − u(t − nTs − 1)]/1 when 1 << Ts. The sampled signal is then given by xs(t) = x(t)δTs (t)
=
n
x(nTs)δ(t − nTs) (7.4)
as illustrated in Figure 7.1.
There are two equivalent ways to view the sampled signal xs(t) in the frequency domain:
n Modulation: Since δTs (t) is periodic, of fundamental frequency s = 2 π/Ts, its Fourier series is
δTs (t) =
k=−∞
Dkejkst
FIGURE 7. Ideal impulse sampling.
t
t
t
×
0
0
0
x ( t )
x (^) s ( t )
Ts 2 Ts
− T (^) s Ts 2 Ts
δTs ( t )
422 CH A P T E R 7: Sampling Theory
where the Fourier coefficients {Dk} are
Dk =
Ts
T∫s/ 2
−Ts/ 2
δTs (t)e−jkstdt =
Ts
T∫s/ 2
−Ts/ 2
δ(t)e−jkstdt
Ts
T∫s/ 2
−Ts/ 2
δ(t)e−j^0 dt =
Ts
The last equation is obtained using the sifting property of the δ(t) and that the area of the impulse is unity. Thus, the Fourier series of the sampling signal is
δTs (t) =
k=−∞
Ts
ejkst^ (7.5)
and the sampled signal xs(t) = x(t)δTs (t) is then expressed as
xs(t) =
Ts
k=−∞
x(t)ejkst
with Fourier transform
Xs() =
Ts
k=−∞
X( − ks) (7.6)
where we used the frequency-shift property of the Fourier transform, and let X() and Xs() be the Fourier transforms of x(t) and xs(t), respectively. n Discrete-time Fourier transform: The Fourier transform of the sum representation of xs(t) in the second equation in Equation (7.4) is
Xs() =
n
x(nTs)e−jTsn^ (7.7)
where we used the Fourier transform of a shifted impulse. This equation is equivalent to Equa- tion (7.6) and will be used later in deriving the Fourier transform of discrete-time signals.
Remarks
n The spectrum Xs() of the sampled signal, according to Equation (7.6), is a superposition of shifted analog spectra {X( − ks)} multiplied by 1 /Ts (i.e., the modulation process involved in the sampling). n Considering that the output of the sampler displays frequencies that are not present in the input, according to the eigenfunction property the sampler is not LTI. It is a time-varying system. Indeed, if sampling x(t) gives xs(t), sampling x(t − τ ) where τ 6 = kTs for an integer k will not be xs(t − τ ). The sampler is, however, a linear system.
424 CH A P T E R 7: Sampling Theory
(a)
(b)
(c)
1
−Ωmax Ωmax
X (Ω)
Ω
No aliasing Ωmax
Ω s ≥ 2 Ωmax
Xs (Ω) 1/ Ts
Ω s Ω
· · ·^ · · ·
Aliasing
Ω s < 2 Ωmax
Xs (Ω) 1/ Ts
Ω s − Ωmax
Ω s = Ωmax Ω
· · · · · ·
FIGURE 7. (a) Spectrum of band-limited signal, (b) spectrum of sampled signal when satisfying the Nyquist sampling rate condition, and (c) spectrum of sampled signal with aliasing (superposition of spectra, shown in dashed lines, gives a constant shown by continuous line).
possible to recover the original continuous-time signal from the sampled signal, and thus the sampled signal does not share the same information with the original continuous-time signal. This phenomenon is called frequency aliasing since due to the overlapping of the spectra some frequency components of the original continuous-time signal acquire a different frequency value or an “alias.” n When the spectrum of x(t) does not have a finite support (i.e., the signal is not band limited) sampling using any sampling period Ts generates a spectrum of the sampled signal consisting of overlapped shifted spectra of x(t). Thus, when sampling non-band-limited signals frequency aliasing is always present. The only way to sample a non-band-limited signal x(t) without aliasing—at the cost of losing information provided by the high-frequency components of x(t) — is by obtaining an approximate signal xa(t) that lacks the high-frequency components of x(t), thus permitting us to determine a maximum frequency for it. This is accomplished by antialiasing filtering commonly used in samplers.
A band-limited signal x(t)—that is, its low-pass spectrum X() is such that
|X()| = 0 for || > max (7.11)
7.2 Uniform Sampling 425
where max is the maximum frequency in x(t)—can be sampled uniformly and without frequency aliasing using a sampling frequency
s = 2 π Ts
≥ 2 max (7.12)
This is called the Nyquist sampling rate condition.
Consider the signal x(t) = 2 cos( 2 πt + π/ 4 ), −∞ < t < ∞. Determine if it is band limited or not. Use Ts = 0.4, 0.5, and 1 sec/sample as sampling periods, and for each of these find out whether the Nyquist sampling rate condition is satisfied and if the sampled signal looks like the original signal or not.
Solution Since x(t) only has the frequency 2π, it is band limited with max = 2 π rad/sec. For any Ts the sampled signal is given as
xs(t) =
n=−∞
x(nTs)δ(t − nTs) Ts sec/sample (7.13)
with x(nTs) = x(t)|t=nTs.
Using Ts = 0.4 sec/sample the sampling frequency in rad/sec is s = 2 π/Ts = 5 π > 2 max = 4 π, satisfying the Nyquist sampling rate condition. The samples in Equation (7.13) are then
x(nTs) = 2 cos( 2 π 0.4n + π/ 4 ) = 2 cos
4 π 5
n +
π 4
− ∞ < n < ∞
The sampled signal xs(t) repeats periodically every five samples. Indeed, for Ts = 0.4,
xs(t + 5 Ts) =
n=−∞
x(nTs)δ(t − (n − 5 )Ts) letting m = n − 5
m=−∞
x((m + 5 )Ts)δ(t − mTs) = xs(t)
since x((m + 5 )Ts) = x(mTs). Looking at Figure 7.3(b), we see that there are three samples in each period of the analog sinusoid, and it is not obvious that the information of the continuous-time signal is preserved. We will show in the next section that it is actually possible to recover x(t) from this sampled signal xs(t), which allows us to say that xs(t) has the same information as x(t). When Ts = 0.5 the sampling frequency is s = 2 π/Ts = 4 π = 2 max, barely satisfying the Nyquist sampling rate condition. The samples in Equation (7.13) are now
x(nTs) = 2 cos( 2 πn0.5 + π/ 4 ) = 2 cos
2 π 2
n +
π 4
− ∞ < n < ∞
7.2 Uniform Sampling 427
Consider the following signals:
(a) x 1 (t) = u(t + 0.5) − u(t − 0.5) (b) x 2 (t) = e−tu(t)
Determine if they are band limited or not. If not, determine the frequency for which the energy of the non-band-limited signal corresponds to 99% of its total energy and use this result to approximate its maximum frequency.
Solution
(a) The signal x 1 (t) = u(t + 0.5) − u(t − 0.5) is a unit pulse signal. Clearly, this signal can be easily sampled by choosing any value of Ts << 1. For instance, Ts = 0.01 sec would be a good value, giving a discrete-time signal x 1 (nTs) = 1, for 0 ≤ nTs = 0.01n ≤ 1 or 0 ≤ n ≤ 100. There seems to be no problem in sampling this signal; however, we have that the Fourier transform of x 1 (t),
ej0.5^ − e−j0.5 j
sin(0.5) 0.5
does not have a maximum frequency and so x 1 (t) is not band limited. Thus, any chosen value of Ts will cause aliasing. Fortunately, the values of the sinc function go fast to zero, so that one could compute an approximate maximum frequency that covers 99% of the energy of the signal. Using Parseval’s energy relation we have that the energy of x 1 (t) (the area under x^21 (t)) is 1 and if we wish to find a value M, such that 99% of this energy is in the frequency band [−M, M], we need to look for the limits of the following integral so it equals 0.99:
2 π
−M
sin(0.5) 0.5
d
Since this integral is difficult to find analytically, we use the following script in MATLAB to approximate it.
%%%%%%%%%%%%%%%%%%%%% % Example 7.2 --- Parseval’s relation and sampling %%%%%%%%%%%%%%%%%%%%% syms W for k = 1:23; E(k) = int((sin(0.5W)/(0.5W))ˆ2,0,k*pi)/pi if E(k)> = 0.9900, k return end end
428 CH A P T E R 7: Sampling Theory
We found that for M = 20 π rad/sec 98.9% of the energy of the signal is included, and thus it could be used to determine that Ts < π/M = 0.05 sec/sample. (b) For the causal exponential x(t) = e−tu(t) its Fourier transform is
X() =
1 + j
so that |X()| =
which does not go to zero for any finite , then x(t) is not band limited. To find a frequency M so that 99% of the energy is in −M ≤ ≤ M, we let
2 π
−M
|X()|^2 d =
2 π
−∞
|X()|^2 d
which gives
2 tan−^1 ()| 0 M= 2 × 0.99 tan−^1 ()|∞ 0 or M = tan
0.99π 2
If we choose s = 2 π/Ts = 5 M or Ts = 2 π/( 5 × 63.66) ≈ 0.02, there will be hardly any aliasing or loss of information. (^) n
If the signal x(t) to be sampled is band limited with Fourier transform X() and maximum frequency max, by choosing the sampling frequency s to satisfy the Nyquist sampling rate condition, or s > 2 max, the spectrum of the sampled signal xs(t) displays a superposition of shifted versions of the spectrum of x(t), multiplied by 1/Ts, but with no overlaps. In such a case, it is possible to recover the original analog signal from the sampled signal by filtering. Indeed, if we consider an ideal low-pass analog filter Hlp(j) with magnitude Ts in the pass-band −s/ 2 < < s/2, and zero elsewhere—that is,
Hlp(j) =
Ts −s/ 2 < < s/ 2 0 elsewhere
the Fourier transform of the output of the filter is Xr () = Hlp(j)Xs() or
Xr () =
X() −s/ 2 < < s/ 2 0 elsewhere
which coincides with the Fourier transform of the original signal x(t). So that when sampling a band- limited signal, using a sampling period Ts that satisfies the Nyquist sampling rate, the signal can be recovered exactly from the sampled signal by means of an ideal low-pass filter.
430 CH A P T E R 7: Sampling Theory
FIGURE 7. Anti-aliasing filtering of non-band-limited signal.
−Ω c
−Ω c
Ω c
Ω c
Ω
1
X (Ω) Xa (Ω)
H ( s )
H ( j Ω)
Ω
Ω
about 5 KHz (this range of frequencies provides understandable speech in phone conversations). Thus, when sampling speech an anti-aliasing filter with a cut-off frequency of 5 KHz is chosen and the sampling rate is then set to 10,000 samples/sec. Likewise, it is also known that an acceptable range of frequencies from 0 to 22 KHz provides music with good fidelity, so that when sampling music signals the anti-aliasing filter cut-off frequency is set to 22 KHz and the sampling rate to 44 K samples/sec or higher to provide good-quality music.
The sampling theory has been attributed to many engineers and mathematicians. It seems as if mathematicians and researchers in communications engineering came across these results from different perspectives. In the engineering com- munity, the sampling theory has been attributed traditionally to Harry Nyquist and Claude Shannon, although other famous researchers such as V. A. Kotelnikov, E. T. Whittaker, and D. Gabor came out with similar results. Nyquist’s work did not deal directly with sampling and reconstruction of sampled signals but it contributed to advances by Shannon in those areas. Harry Nyquist was born in Sweden in 1889 and died in 1976 in the United States. He attended the University of North Dakota at Grand Forks and received his Ph.D. from Yale University in 1917. He worked for the American Telephone and Telegraph (AT&T) Company and the Bell Telephone Laboratories, Inc. He received 138 patents and published 12 technical articles. Nyquist’s contributions range from the fields of thermal noise, stability of feedback amplifiers, telegraphy, and television, to other important communications problems. His theoretical work on determining the bandwidth requirements for transmitting information provided the foundations for Claude Shannon’s work on sampling theory [33]. As Hans D. Luke [44] concludes in his paper “The Origins of the Sampling Theorem,” regarding the attribution of the sampling theorem to many authors: This history also reveals a process which is often apparent in theoretical problem in technology or physics: first the practicians put forward a rule of thumb, then theoreticians develop the general solution, and finally someone discovers that the mathematicians have long since solved the mathematical problem which it contains, but in “splendid isolation.”
Consider the two sinusoids
x 1 (t) = cos( 0 t) − ∞ ≤ t ≤ ∞
x 2 (t) = cos(( 0 + s)t) − ∞ ≤ t ≤ ∞
7.2 Uniform Sampling 431
Show that if we sample these signals using Ts = 2 π/s, we cannot differentiate the sampled signals (i.e., x 1 (nTs) = x 2 (nTs)). Use MATLAB to show the above graphically when 0 = 1 and s = 7. Explain the significance of this.
Solution Sampling the two signals using Ts = 2 π/s, we have
x 1 (nTs) = cos( 0 nTs) − ∞ ≤ n ≤ ∞
x 2 (nTs) = cos(( 0 + s)nTs) − ∞ ≤ n ≤ ∞
but since sTs = 2 π, the sinusoid x 2 (nTs) can be written as
x 2 (nTs) = cos(( 0 Ts + 2 π)n)
= cos( 0 Tsn) = x 1 (nTs)
The following script shows the aliasing effect when 0 = 1 and s = 7 rad/sec. Notice that x 1 (t) is sampled satisfying the Nyquist sampling rate condition (s = 7 > 2 0 = 2 rad/sec), while x 2 (t) is not (s = 7 < 2 ( 0 + s) = 16 rad/sec).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Example 7.3 ---Two sinusoids of different frequencies being sampled % with same sampling period -- aliasing for signal with higher frequency %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all; clf % sinusoids omega 0 = 1;omega s = 7; T = 2 ∗ pi/omega 0; t = 0:0.001:T; % a period of x x1 = cos(omega 0 ∗ t); x2 = cos((omega 0 + omega s) ∗ t); N = length(t); Ts = 2 ∗ pi/omega s; % sampling period M = fix(Ts/0.001); imp = zeros(1,N); for k = 1:M:N − 1. imp(k) = 1; % sequence of impulses end xs = imp. ∗ x1; % sampled signal plot(t,x1,’b’,t,x2,’k’); hold on stem(t,imp. ∗ x1,’r’,’filled’);axis([0 max(t) − 1.1 1.1]); xlabel(’t’); grid
Figure 7.5 shows the two sinusoids and the sampled signal that coincides for the two signals. The result in the frequency domain is shown in Figure 7.6: The spectra of the two sinusoids are different but the spectra of the sampled signals are identical. n
7.2 Uniform Sampling 433
−∞
n
x(nTs)δ(τ − nTs)
hlp(t − τ )dτ
n
x(nTs)
sin(π(t − nTs)/Ts) π(t − nTs)/Ts
after replacing xs(τ ) and applying the sifting property of the delta function. The recovered signal is thus an interpolation in terms of time-shifted sinc signals with amplitudes the samples {x(nTs)}. In fact, if we let t = kTs, we can see that
xr (kTs) =
n
x(nTs)
sin(π(k − n)) π(k − n)
= x(kTs)
since sin(π(k − n)) π(k − n)
1 k − n = 0 or k = n 0 k 6 = n This is because the above sinc function by L’H ˆopital’s rule is shown to be unity when k = n, and it is 0 when k 6 = n since the sine is zero at multiples of π. Thus, the values at t = kTs are recovered exactly, and the rest are interpolated by a sum of sinc signals.
The simulation of sampling with MATLAB is complicated by the representation of analog signals and the numerical computation of the analog Fourier transform. Two sampling rates are needed: one being the sampling rate under study, fs, and the other being the one used to simulate the analog signal, fsim >> fs. The computation of the analog Fourier transform of x(t) can be done approximately using the fast Fourier transform (FFT) multiplied by the sampling period. For now, think of the FFT as an algorithm to compute the Fourier transform of a discretized signal. To illustrate the sampling procedure consider sampling a sinusoid x(t) = cos( 2 πf 0 t) where f 0 = 1 KHz. To simulate this as an analog signal we choose a sampling period Tsim = 0.5 × 10 −^4 sec/sample or a sampling frequency fsim = 20, 000 samples/sec.
No aliasing sampling—If we sample x(t) with a sampling frequency fs = 6000 > 2 f 0 = 2000 Hz, the sampled signal y(t) will not display aliasing in its frequency representation, as we are satisfying the Nyquist sampling rate condition. Figure 7.7(a) displays the signal x(t) and its sampled version y(t), as well as their approximate Fourier transforms. The magnitude spectrum |X()| corresponds to the sinusoid x(t), while |Y()| is the first period of the spectrum of the sampled signal (recall the spec- trum of the sampled signal is periodic of period s = 2 πfs). In this case, when no aliasing occurs, the first period of the spectrum of y(t) coincides with the spectrum of x(t) (notice that as a sinusoid, the magnitude spectrum |X()| is zero except at the frequency of the sinusoid or ±1 KHz; likewise |Y()| is zero except at ±1 KHz and the range of frequencies is [−fs/2, fs/2] = [−3, 3] KHz). In Figure 7.7(b) we show the sinc interpolation of three samples of y(t); the solid line is the interpolated values or the sum of sincs centered at the three samples. At the bottom of that figure we show the sinc interpola- tion, for all the samples, obtained using our function sincinterp. The sampling is implemented using our function sampling.
434 CH A P T E R 7: Sampling Theory
0 1 2 3 4 5 6 7
− 1
0
1
t (sec)
x (
t ) , y
( t )
x (
t ) x
( r t )
(a) (b)
− 10 − 8 − 6 − 4 − 2 0 2 4 6 8
0
− 3 − 2 − 1 0 1 2
0
f (KHz)
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
−0.
0
1
0 1 2 3 4 5 6
− 1
−0.
0
1
t (sec)
× 10 −^3
× 10 −^4
× 10 −^3
| X
(Ω
)|
| Y
(Ω
)|
Interpolated (^) sinc
Analog signal Sampled signal
FIGURE 7. No aliasing: sampling simulation of x(t) = cos( 2000 πt) using fs = 6000 samples/sec. (a) Plots are of the signal x(t) and the sampled signal y(t), and their spectra (|Y()| is periodic and so a period is shown). (b) The top plot illustrates the sinc interpolation of three samples, and the bottom plot is the sinc-interpolated signal xr (t) and the sampled signal. In this case xr (t) is very close to the original signal.
Sampling with aliasing—In Figure 7.8 we show the case when the sampling frequency is fs = 800 < 2 fs = 2000, so that in this case we have aliasing. This can be seen in the sampled signal y(t) in the top plot of Figure 7.8(a), which appears as if we were sampling a sinusoid of lower frequency. It can also be seen in the spectra of x(t) and y(t): |X()| is the same as in the previous case, but now |Y()|, which is a period of the spectrum of the sampled signal y(t), displays a frequency of 200 Hz, lower than that of x(t), within the frequency range [−400, 400] Hz or [−fs/2, fs/2]. Aliasing has occurred. Finally, the sinc interpolation gives a sinusoid of frequency 0.2 KHz, different from x(t).
Similar situations occur when a more complex signal is sampled. If the signal to be sampled is x(t) = 2 − cos(πf 0 t) − sin( 2 πf 0 t) where f 0 = 500 Hz, if we use a sampling frequency of fs = 6000 > 2 fmax = 2 f 0 = 1000 Hz, there will be no aliasing. On the other hand, if the sampling frequency is fs = 800 < 2 fmax = 2 f 0 = 1000 Hz, frequency aliasing will occur. In the no aliasing sampling, the spectrum |Y()| (in a frequency range [−3000, 3000] = [−fs/2, fs/2]) corresponding to a period of the Fourier transform of the sampled signal y(t) shows the same frequencies as |X()|. The recon- structed signal equals the original signal. See Figure 7.9(a). When we use fs = 800 Hz, the given signal x(t) is undersampled and aliasing occurs. The spectrum |Y()| corresponding to a period of the Fourier transform of the undersampled signal y(t) does not show the same frequencies as |X()|. The reconstructed signal shown in the bottom right plot of Figure 7.9(b) does not resemble the original signal.