Reconstruction and Interpolation
5.4 Reconstruction and Interpolation
In many practical applications, discrete-time sequences are required to be trans- formed into continuous-time signals. In computer-controlled systems, it is necessary to convert the control actions calculated by the computer as a sequence of numbers into a continuous-time signal that can be applied to the plant or process. In digital audio compact disk system, the audio signals are stored as digital samples on the disk and must ultimately be converted into analog signals to drive the speakers. In these cases, we are faced with the inverse of the sampling operation, which asks us
to think about how to reproduce the analog signal x a (t ) from the continuous-time sampled signal x ∗ (t ) = x a (t )δ T (t ) or discrete-time sequence x d [n] = x a (nT ).
5.4.1 Shannon Reconstruction
We begin by considering the un-aliased spectrum X ∗ (ω) as shown in Fig. 5.8(b) where X ∗ (ω) has the same shape with the original spectrum X a (ω) over the principal frequency range (−π/T, π/T ) where T is the sampling interval or period. Sup- pose we have an analog lowpass filter (LPF) with the ideal ‘brick wall’ frequency response
which passes only frequencies in the range |ω| ≤ π/T and masks out all other frequencies. Recall from Eq. (E2.9.2) that
g I (t ) = F −1
{G B=π/T
I (ω)} = T sinc
(E2.9.2)
= sinc (5.4.2) T
We can apply this filter to X ∗ (ω) to retrieve the original spectrum X a (ω) in the frequency domain as
(5.4.3) or in the time domain as
X (ω) = G I (ω)X ∗ (ω)
264 5 Sampling and Reconstruction
x (E2.13.1) (t ) = F −1 {X(ω)} =g
(t )δ(t − mT ) = g I (t ) ∗
(mT )δ(t − mT )
ˆx(t) ∞ = x a (mT ) sinc (5.4.4)
m =−∞
The above summation (5.4.4), called Whittaker’s cardinal interpolation formula or Whittaker-Shannon sampling series [S-1, W-1], suggests a reconstruction formula. It can be modified into a more computationally-efficient form
ˆx(t) = x a (mT ) (−1)
sin(π t / T )
t − mT where we have used the fact that
sin(m π ) = (−1) sin t T
cos(m π ) − cos
T Since the sinc function sinc(t − mT ) has unity value for t = mT and becomes zero
for other Shannon reconstruction sample points, it is obvious that
ˆx(nT ) = x a (nT ) ∀ integer n
(5.4.6) holds for every sample point. The role of g I (t ) is to fill in or interpolate the values
of the continuous-time function between the sample points.
%sig05f13.m clear, clf ts=0.001; T=0.1; tt=-0.5:ts:1.4; t0=0; tf=1; % Time range fs=[0 0.1 0.2 0.3 0.4 0.5]; ws=2*pi*fs/T; % Frequencies contained in x(t) Aks= [1 1 1 1 1 1]; phiks= [0.5 -0.5 0.5 -0.5 1 -1]; K=6; xt= Aks(1)*sin(ws(1)*tt + phiks(1)); for k=2:K, xt = xt + Aks(k)*sin(ws(k)*tt + phiks(k)); end nT= tt([1:T/ts:end]); % Sampling point vector xn= xt([1:T/ts:end]); % Discrete-time sequence sampled with T=0.1 sincmT= inline(’sinc(t/T)’,’t’,’T’); plot(tt,xt), hold on, stem(nT,xn) xht= 0; for n=1:length(xn)
xn sincnT = xn(n)*sincmT(tt-nT(n),T); xht = xht + xn sincnT; %Eq.(5.4.4) plot(tt,xn sincnT,’:’)
end plot(tt,xht,’r’), set(gca,’XLim’,[t0 tf],’fontsize’,9)
5.4 Reconstruction and Interpolation 265 3
:x a (mT )sinc (t – mT ) : x (t ) ^ –3
(a) An example of Whittaker–Shannon reconstruction when the precondition of the sampling theorem is satisfied
(b) An example of Whittaker–Shannon reconstruction when the precondition of the sampling theorem is not satisfied
Fig. 5.13 Examples of Whittaker–Shannon reconstruction
Interested readers are recommended to run the above program “sig05f13.m” twice, once with the number of frequencies K = 5 and once with K = 6, to get
Fig. 5.13(a) and (b), respectively and then, think about what the difference comes from in connection with the precondition of the sampling theorem.
5.4.2 DFS Reconstruction
Recall again the relationship (5.3.1a) between the CTFS X k of a continuous-time periodic signal ˜x P (t ) and the N -point DTFS (DFS/DFT) ˜ X N (k) of the discrete-time version ˜x N [n] = ˜x P (nT ) (obtained by sampling ˜x P (t ) every T s), which is periodic with period N = P/T in n:
X (3.5.3) or (5.3.1a) ˜
This implies that if ˜x P (t ) does not contain the frequencies above the folding frequency, i.e., half the sampling frequency
266 5 Sampling and Reconstruction ω s
2 P = 2 (corresponding to the frequency index k = 2 so that
X k = 0 ∀ |k| ≥
then Eq. (5.4.7) becomes ˜
X N (k)
(5.4.7) with (5.4.8)
X k for |k| < (5.4.9)
2 This suggests another reconstruction formula, called the DFS reconstruction, which
is similar to the inverse DFS formula (3.4.8):
X ˜ N (k)e j ˆx(t) = 2π kt/N T
| k|<N/2
%sig05f14.m clear, clf ts=0.001; T=0.1; tt=-0.5:ts:1.4; t0=0; tf=1; fs=[0 0.1 0.2 0.3 0.4 0.5]; ws=2*pi*fs/T; % Frequencies contained in x(t) Aks= [1 1 1 1 1 1]; phiks= [0.5 -0.5 0.5 -0.5 1 -1]; K=5; xt= Aks(1)*sin(ws(1)*tt + phiks(1)); for k=2:K, xt = xt + Aks(k)*sin(ws(k)*tt + phiks(k)); end nT= tt([1:T/ts:end]); xn= xt([1:T/ts:end]); xn causal=[xn(6:end) xn(1:5)]; Xk= fft(xn causal); N=length(Xk); plot(tt,xt), hold on, stem(nT,xn) kk1=[1:N/2].’; xht1 DFS= real(Xk(kk1)*exp(j*2*pi/N/T*(kk1-1)*tt))/N; kk2=[N/2+2:N].’; xht2 DFS= real(Xk(kk2)*exp(j*2*pi/N/T*(kk2-1-N)*tt))/N; xht DFS = xht1 DFS + xht2 DFS; plot(tt,xht DFS,’r’), set(gca,’XLim’,[t0 tf],’fontsize’,9)
Interested readers are recommended to run the above program “sig05f14.m” twice, once with the number of frequencies K = 5 and once with K = 6, to get
Fig. 5.14(a) and (b), respectively and then, think about what the difference comes from in connection with the precondition of the sampling theorem.
5.4 Reconstruction and Interpolation 267 x a (t )
2 ^ x (t ) Overlapped 1 0 t
(a) An example of Fourier series reconstruction when the precondition of the sampling theorem is satisfied
x a (t ) 2 x (t ) ^
–2 (b) An example of Fourier series reconstruction
when the precondition of the sampling theorem is not satisfied Fig. 5.14 Examples of Fourier series reconstruction
5.4.3 Practical Reconstruction
The problem with the ideal (Whittaker-Shannon) interpolation function g I (t ) = sinc(t / T ) is that it extends in time from t = −∞ to +∞ and accordingly, it incor- porates the entire sequence of x a (nT ) including all the future samples (for n > 0) as well as all the past samples (for n < 0) to find the estimate of x(t ). Besides, in control situations we cannot usually wait to observe the entire sequence before an interpolation is performed. In this section we consider a practical interpolator called the zero-order hold (z.o.h.), which is a causal lowpass filter to approximate a signal
between two consecutive sampling instants nT and (n + 1)T by a constant x a (nT ). This is the beginning of the story about the ideal S/H (sample-and-hold device). As
depicted in Fig. 5.15(a), the output of a z.o.h. to an input x(t ) can be described as
(t − nT ) − u s (t − nT − T )) (5.4.11) whose Laplace transform is
B.8(3), B.7(2)
a (nT )e −nT s 1
(1 − e −T s ); (5.4.12)
n=0
X (s) = X ∗ (s) G h 0 (s)
268 5 Sampling and Reconstruction
S/H (a) The input and output of a S/H
0 : Input to S/H
x (t ) : Output from S/H
x a (t )
x * (t ) z.o.h. G h0 (s) x (t ) G h0 ( j ω)
x a (t )
X * (s) (c) A S/H and its model
(b) The magnitude response of a z.o.h. Fig. 5.15 S/H (Sample–and–Hold) modeled by combining an ideal sampler and a z.o.h.
δ n=−∞ (t − nT )
=X d [z] | z=e sT (5.4.14)
n=−∞
X ∗ (s) (5.4.14) s (1 − e −T s )
(5.4.13) X (s) (5.4.12) 1
G h 0 (s) =
Note that in Eq. (5.4.13) describing the Laplace transform of the z.o.h. output,
X ∗ (s) is the Laplace transform of x ∗ (t ) = x a (t )δ T (t ) (the output of an ideal sampler to x a (t )), called the starred transform of x a (t ). On the other hand, G h 0 (s) can be regarded as the system or transfer function of the z.o.h. device since it does not depend on x a (t ). Hence the frequency response of the z.o.h. is
jω sin(ωT /2)
which implies that the z.o.h. is a kind of lowpass filter (see Fig. 5.15(b)). Note that x ∗ (t ) is not present in physical systems, but it appears in the mathematical model as a result of factoring and can be considered to be the output of an ideal sampler. Although the ideal sampler and the z.o.h. do not individually model a physical sam- pler and a physical data hold, their combination does accurately model a physical S/H device (see Fig. 5.15(c)).
5.4 Reconstruction and Interpolation 269
5.4.4 Discrete-Time Interpolation
As mentioned in Remark 3.7(4), zero-padding in the time domain can be used to increase the frequency resolution, which is justified for finite-duration signals that have already been sampled over all nonzero portions. In duality with this, zero- padding in the frequency domain can be used to increase the time resolution, which is justified for bandlimited signals having nonzero spectral values only for some finite frequency range. This suggests us a discrete-time interpolation method.
Suppose we are given a sequence {x[n], n = 0 : N − 1} where X(Ω) = F{x[n]} ≃ 0 for the frequency range near Ω = π. We first obtain the N -point DFT of x[n], i.e., X (k) = DFT N {x[n]} for k = 0 : N − 1 and then pad it with some, say, (K − 1)N zeros to make a new KN -point DFT sequence V (k) as follows:
< case 1: N is even> ⎧
0 ≤ k ≤ (N/2) − 1 and ⎪ ⎨
⎪ K˜ X (k)
for
V (k) = K N − (N/2) + 1 ≤ k ≤ K N − 1 (5.4.17a)
⎪ ⎪ (K /2) ˜ X (k) for k = N/2, K N − (N/2) ⎩ ⎪ 0 elsewhere (zero-padding)
< case 2: N is odd> ⎧
⎪ ⎨ K˜ X (k) for 0 ≤ k ≤ (N − 1)/2 and
V (k) = K N − (N − 1)/2 ≤ k ≤ K N − 1 (5.4.17b)
⎩ ⎪ 0 elsewhere (zero-padding)
where ˜ X (k) = DFS N {x[n]} is the periodic repetition of X(k) with period N . Now we compute the KN -point IDFT of V (k) to obtain an interpolation of
x [n] as v [n] = IDFT KN {V (k)}
1 K N −1 (k) e j = 2π kn/K N V KN
for n = 0, 1, ···,KN−1 (5.4.18)
k=0
To evaluate this expression at every K th element, we substitute n = K m to get
1 N −1 v [K m] =
X ˜ (k) e j 2π km/N
k=0
(5.4.19) This implies that the new sequence v[n] has been obtained by placing (K − 1)
= IDFT N {X(k)} = x[m] for m = 0, 1, · · · , N − 1
samples between successive samples of the original sequence x[n].
270 5 Sampling and Reconstruction (Q) In the case where x[n] is a real-valued sequence, it seems that we need to
ensure the conjugate symmetry of its K N -point DFT V (k) by modifying a part of Eq. (5.4.17a) as
for k = N/2
V (k) = (5.4.20) (K /2) ˜ X ∗ (k) for k = K N − (N/2)
However, we do not have to take the complex conjugate of ˜ X (N /2) since it is real for a real-valued sequence x[n].
Remark 5.3 Discrete-Time Interpolation, Zero Insertion, and Lowpass Filtering The DFT sequence V (k) is the same as the DFT of the output sequence of an ideal lowpass filter (with gain K and bandwidth π/K ) to the input signal x (K ) [n], which is obtained by inserting (K − 1) zeros between successive sample points of x [n]. From Eq. (3.2.14), we know that the K N -point DFT of x (K ) [n] is
X KN (k) = ˜X N (k) for k = 0, 1, · · · , (K N − 1) : the periodic repetition of X (k) with period N
Note that Eq. (5.4.17) is equivalent to taking a scaled version of X K (k) within the low frequency band, which corresponds to a lowpass filtering (see Fig. 5.16(b2)).
Example 5.1 Discrete-Time Interpolation Let us find a discrete-time interpolation for the following sequence (see Fig. 5.16(a1)):
n=0
(E5.1.1) We first compute the N = 4 -point DFT of x[n] as (see Fig. 5.16(b1))
x [n] = {2, 1, 0, 1}
(k) = DFT 3 x
X N −1 nk N {x[n]} =
x [n] e − j2πnk/N
X (k) = {4, 2, 0, 2} (E5.1.2) Then we use Eq. (5.4.17) with K = 2 to get V (k) as (see Fig. 5.16(b3))
(E5.1.3) Now, we compute the K N = 8 -point IDFT of V (k) to obtain the interpolated
k=0
V (k) = {8, 4, 0, 0, 0, 0, 0, 4}
sequence v[n] (see Fig. 5.16(a3)):
5.4 Reconstruction and Interpolation 271
2 X (k ) 1 0 0 0 0 1 2 3 n 0 0 1 2 3 k (a1) x [n]
1 x [n]
1 DFT
(b1) X (k ) = DFT{x [n]} Zero–insertion
Ideal LPF frequency response 2 4 4 ~
[n] X (k) 1 (2)
up-sampling
0 1 2 3 4 5 6 7 k (a2) x (2) [n]: zero–inserted
(b2) X (k): a periodic repetition of X (k) Zero-padding
down-sampling (decimation) Lowpass–filtering
(a3) v [n]: lowpass–filtered (b3) V (k): zero–padded
Fig. 5.16 Discrete-time interpolation of a discrete-time sequence
v [n] = IDFT j KN 2π k n/8 {V (k)} = V (k) e
+ 4e − jπkn/4 ) = 1 + cos
kπ n ; (E5.1.4)
n=0 1 2 3 4 5 6 7
v [n] = {2, 1.707, 1, 0.293, 0, 0.293, 1, 1.707}
This result can also be obtained by using the MATLAB routine ‘ interpolation discrete()’, which implements the procedure described by Eq. (5.4.17) and (5.4.18).
>>x=[2 1 0 1]; K=2; >>v=interpolation discrete(x,K)
function [xi,Xi]=interpolation discrete(x,K) % To find the KN-point discrete-time interpolation xi of an N-point % discrete-time sequence x[n] N=length(x); KN=K*N; N1=floor((N+1)/2); KNN1=KN-N1+2; X= fft(x); Xi= K*X(1:N1); Xi(KNN1:KN)=K*X(N-N1+2:N); % Eq.(5.4.17) if mod(N,2)==0, Xi([N/2+1 KN-N/2])=K/2*X(N/2+1)*[1 1]; end % Eq.(5.4.17b) xi= ifft(Xi); % Eq. (5.4.18)
272 5 Sampling and Reconstruction