2.161 Signal Processing: Continuous and Discrete: Mit Opencourseware
2.161 Signal Processing: Continuous and Discrete: Mit Opencourseware
2.161 Signal Processing: Continuous and Discrete: Mit Opencourseware
http://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
1 1
(a) original data set (b) interpolated data set
(8 samples) (32 samples)
0.5 0.5
0 0
−0.5 −0.5
−1 −1
2 4 6 8 10 20 30
Figure 1: (a) a data set with N = 8 samples, and (b) an interpolated data set (K = 4) derived
from (a).
1
D. Rowell August 18, 2008
1
• Let F (jΩ) = F {f (t)} be the Fourier transform of f (t), and let f (t) be sampled at intervals
ΔT to produce f ∗ (t). Then
∞ � � ��
∗ 1 � 2πn
F (jΩ) = F j Ω− (1)
ΔT n=0 ΔT
is periodic with period 2π/ΔT , and consists of scaled and shifted replicas of F (jΩ). Let the
total sampling interval be T to produce N = T /ΔT samples.
• If the same waveform f (t) is sampled at intervals ΔT /K to produce fˆ∗ (t) the period of its
Fourier transform F̂ ∗ (jΩ) is 2πK/ΔT and
∞ � � ��
ˆ ∗ K � 2πKn
F (jΩ) = F j Ω− (2)
ΔT n=0 ΔT
which differs only by a scale factor, and an increase in the period. Let the total sampling
period be T as above, to generate KN samples.
• We consider the DFTs to be sampled representations of a single period of F ∗ (jΩ) and F̂ ∗ (jΩ).
The equivalent line spacing in the DFT depents only on the total duration of the sample set
T , and is ΔΩ = 2π/T in each case:
� � ��
∗2πm
Fm = F j , m = 0, 1, . . . N − 1
T
� � ��
2πm
F̂m = F̂ ∗ j , m = 0, 1, . . . KN − 1.
T
� �
From Eqs. (1) and (2) the two DFTs {Fm } and Fˆm are related:
⎧
⎪
⎨ KFm m = 0, 1, . . . , N/2 − 1
F̂m = 0 m = N/2, . . . , N K − N/2 − 1
⎪
⎩ KF
m−(K−1)N m = N K − N/2, . . . , KN − 1
• The effect of increasing N (or decreasing ΔT ) in the sample set, while maintaining T = N ΔT
constant, is to increase the length of the DFT by raising the effective Nyquist frequency ΩN .
π Nπ
ΩN = =
ΔT T
Figure 2 demonstrates these effects by schematically, by comparing the DFT of (a) a data set
of length N derived by sampling at intervals ΔT , and (b) a data set of length 2N resulting from
sampling at intervals ΔT /2. The low frequency region of both spectra are similar, except for a
scale factor, and the primary difference lies in the “high frequency” region, centered around the
Nyquist frequency, in which all data points are zero.
The above leads to an algorithm for the interpolation of additional points into a data set, by a
constant factor K:
1. Take the DFT of the original data set to create {Fm } of length N .
2. Insert (K − 1)N zeros into the center of the DFT to create a length KN array.
3. Take the IDFT of the expanded array, and scale the sequence by a factor K.
Appendix A describes a simple MATLAB function to interpolate a real data set using this method.
F
m
N u m b e r o f s a m p le s : N
S a m p lin g in te r v a l: D T
N y q u is t fr e q u e n c y
-N /2 0 N /2 N 3 N /2 2 N m
(a )
F
m
N u m b e r o f s a m p le s : 2 N
S a m p lin g in te r v a l: D T /2
N y q u is t fr e q u e n c y
0 N 2 N m
(b )
Figure 2: Envelopes of (a) the DFT of a sample set with N samples, and (b) the DFT of the same
waveform with 2N samples.
However, only the original N samples contribute to the sum, so that we can write
N
� −1
2πmk
F̂m = fˆKk e−j N
k=0
= Fm , m = 0 . . . KN − 1
since fˆKk = fk . We note that {Fm } is periodic with period N , and {F̂m } is periodic with period
KN , so that {F̂m } will contain K repetitions of {Fm }. This is illustrated in Fig. 4, which shows
f 3
n
0 n
0 1 2 3 4 5 6 7
(a) Initial data set, N=8
f 3
n
2
0 n
0 5 10 15 20
(b) Data set with two samples interpolated between samples, N=24
Figure 3: (a) A sample set with N = 8 samples, and (b) the same waveform with 2 zero amplitude
samples interpolated between each of the original samples.
F 10
m
8
2
m
0
0 1 2 3 4 5 6 7
(a) DFT of Initial data set, N=8
^
F 10
m
8
2
m
0
0 5 10 15 20
(b) DFT of data set with two samples interpolated between samples, N=24
Figure 4: (a) DFTs of the sample sets shown in Fig. 3. In (a) the DFT {Fm } is periodic with
period 8, and in (b) the DFT {F̂m } is periodic with period 24.
the magnitude of the DFTs of the two waveforms in Fig. 3. The effect of inserting the K − 1 zeros
between the original samples has been to generate a waveform with an equivalent sampling interval
of ΔT /K s, and a Nyquist frequency of Kπ/ΔT rad/s. The line resolution is unchanged, and the
original DFT {Fm } is replicated K times within the frequency span of 2Kπ/ΔT rad/s.
The fully interpolated waveform may be reconstructed by elimination of the replications of the
original spectral components. While this might be done in the frequency domain, the most common
method is to low-pass filter the padded data sequence to retain only the base-band portion of the
spectrum as shown in Fig. 5.
^
F m lo w - p a s s filte r
p a s s b a n d r e p lic a tio n s o f F
N y q u is t
fre q u e n c y
0 K N /2 K N
w = K p /D T w = 2 K p /D T
lo w - p a s s
d ig ita l filte r
^
F m
0 K N /2 K N
w = K p /D T w = 2 K p /D T
Figure 5: Digital low-pass filtering used to eliminate spectral replications introduced by extra
samples inserted into the waveform.
~ ^
f(t)
A n ti- a lia s in g f(t) S a m p le r K {fn } L o w - p a s s d ig ita l
lo w - p a s s filte r filte r
D T In s e rt K -1 z e ro s
F ( jW ) H ( jW ) = 0 , |W |> p /D T F ( jW ) H ( jW ) { fn } H (z ) i n t e r p o l a t e d
b e tw e e n s a m p le s
w a v e fo rm
c o n tin u o u s d o m a in d is c r e te d o m a in
D T /K
5
which is clearly acausal. An FIR approximation to the ideal interpolator is obtained by truncating
hn to a finite length, say N = 2KM + 1, and delaying it by KM samples so that
sin (π (n − KM ) /K)
hn = n = 0, 1, 2 . . . N − 1
π (n − KM ) /K
and windowing with an appropriate window, for example a Kaiser or Hamming window. The
transfer function may be written
M
� −1
H(z) = bn z −n .
n=0
Figure 7 shows the complete interpolation scheme for an up-sampling factor K = 3.
i = 0 : f n 0 0 f n -1 0 0 . . .
i = 1 : 0 f n 0 0 f n -1 0 . . .
i = 2 : 0 0 f n 0 0 f n -1 . . .
f
fn K
K n + i
z -1
z -1
z -1
z -1
z -1
z -1
u p s a m p le
b 0 b 1 b 2 b 3 b 4 b 5 b b
M M -1
+ + + + + +
+ + + + + +
^
fK
+ +
n + i
s a m p lin g in te r v a l s a m p lin g in te r v a l
, T
(3) At each major time step the interpolated data stream may be created by passing the data
sequence {fn } through each of the sub-filters, so that the interpolated value fˆKn+i is the
output of sub-filter i. The polyphase structure is shown in Fig. 8
Note that it is not necessary to perform the up-sampling step of inserting zero data points into the
data steam with this method.
6
^f
f n n K
s u b - filte r 0
^f
n K + 1
s u b - filte r 1
^f ^f
n K + 2 n K + i
s u b - filte r 2
, T /K
^f
(n + 1 )K -1
s u b - filte r K - 1
, T L , T
t t
D o w n - s a m p le r
Figure 9: Basic temporal down-sampling by an integer factor L. Every Lth sample of the input
sequence is retained in the output; all other data points are “thrown away”.
7
, T , T L , T
t t
D ig ita l lo w - p a s s D o w n - s a m p le r
a n ti- a lia s in g filte r L
Figure 10: Temporal down-sampling by an integer factor L with a digital low-pass filter to eliminate
components in the input sequence that would cause aliasing through the down-sampling operation.
where N and M are positive integers. This can be achieved by (1) interpolation by a factor N ,
followed by (2) decimation by a factor M , as shown in Fig. 11(a). However, since the two low-pass
filters are cascaded, they may be replaced with a single filter with a cut-off frequency that is the
lower of the two filters as is shown in Fig. 11(b).
in te r p o la tio n d e c im a tio n
(a )
u p - s a m p le r lo w - p a s s filte r d o w n - s a m p le r
{ fn } ^
N { fm }
H lp (z ) M
(b )
Y = INTERP(X,R) resamples the sequence in vector X at R times the original sample rate. The
resulting resampled vector Y is R times longer, LENGTH(Y) = R*LENGTH(X).
8
Y = DECIMATE(X,R) resamples the sequence in vector X at 1/R times the original sample rate. The
resulting resampled vector Y is R times shorter, i.e., LENGTH(Y) = CEIL(LENGTH(X)/R).
By default, DECIMATE filters the data with an 8th order Chebyshev Type I low-pass filter
with cutoff frequency .8*(Fs/2)/R, before resampling.
Y = DOWNSAMPLE(X,N) downsamples input signal X by keeping every Nth sample starting with the
first. If X is a matrix, the down-sampling is done along the columns of X.
Y = UPSAMPLE(X,N) upsamples input signal X by inserting N-1 zeros between input samples. X
may be a vector or a signal matrix (one signal per column).
% Note: MATLAB does not require its FFT routine to be restricted to radix-2
%----------------------------------------------------------------------------
N = length(fin);
Fin = fft(fin);
% Create an extended empty array, and fill the ends with the upper and lower
Fout = zeros(length(Fin)*K,1);
Fout(1:N/2) = Fin(1:N/2);
% Take the inverse DFT, scale by K, and preserve the real part
fout = real(ifft(Fout))*K;
%----------------------------------------------------------------------------
9
Example: The following MATLAB fragment creates a data record of length 8, then uses
dftupsample() to up-sample by a factor of K = 11:
>> i=[0:7];
>>
Plots of the input and output data sets are shown in Fig. 12.
−5
0 1 2 3 4 5 6 7 8
(a) time (s)
5
−5
0 1 2 3 4 5 6 7 8
(b) time (s)
Figure 12: Matlab example: (a) input data sequence of length 8, and (b) output data sequence of
length 88.
10