You are on page 1of 26

Sampling and Reconstruction

of Analog Signals
Lecture 5
Sampling and reconstruction of analog
signals
Analogy signals can be converted into discrete signals using
sampling and quantization operations: analogy-to-digital
conversion, or ADC
Digital signals can be converted into analog signals using a
reconstruction operation: digital-to-analogy conversion, or DAC
Using Fourier analysis, we can describe the sampling operation
from the frequency-domain view-point, analyze its effects and then
address the reconstruction operation.
We will also assume that the number of quantization levels is
sufficiently large that the effect of quantization on discrete signals
is negligible.
Sampling
Continuous-time Fourier transform and inverse CTFT

+


+


=
=
d e j X t x
dt e t x j X
t j
a a
t j
a a
) (
2
1
) (
) ( ) (

1. Absolutely integrable
2. Omega is an analogy frequency in radians/sec
Sampling
Sample x
a
(t) at sampling interval T
s
sec apart to obtain the discrete-
time signal x(n)
Let X(e
j
) be discrete-time Fourier transform of x(n).
X(e
j
) is a countable sum of amplitude-scaled, frequency-scaled,
and translated version of the Fourier transform X
a
(j)
) ( ) (
s a
nT x n x =
This is known as the aliasing formula

+
=

=
l
s s
a
s
j
l
T T
j X
T
e X

2 1
) (
The analog and digital frequencies
s
s
s
T
F
T w
1
=
=
F
s
: the sampling frequency, sam/sec
Amplitude scaled factor: 1/T
s
;
Frequency-scaled factor: =T
s
(=0~2)
Frequency-translated factor: 2k/T
s
;

+
=

=
l
s s
a
s
j
l
T T
j X
T
e X

2 1
) (
The discrete signal is an aliased
version of the corresponding
analog signal
It is possible to recover X
a
(j)
from X(e
j
), or x
a
(t) from x(n)
if the infinite replicas of X
a
(j)
do not overlap with each other
to form X(ejw).
This is true for band-limited
analog signals.
Suppose signal band is
limited to
0
,
If T
s
is small,
0
T
s
<, or
F
0
=
0
/2 < Fs/2=1/2T
s
Then the freq. Resp. of x(t)
is an infinite replica series
of its analog signal x
a
(t),
If T
s
is large,
0
T
s
>, or
F
0
=
0
/2 > Fs/2=1/2T
s
Then the freq. Resp. of x(t)
is a overlaped replica of its
analog signal x
a
(t), so
cannot be reconstructed

+
=

=
l
s s
a
s
j
l
T T
j X
T
e X

2 1
) (
Ban-limited signal
A signal is band-limited if there exists a finite radians frequency
0
such that X
a
(j ) is zero for | |>
0
.
The frequency F
0
=
0
/2pi is called the signal bandwidth in Hz
Referring to this picture, if pi>
0
T
s
, then
s s s s
a
s
jw
T T
w
T T
w
j X
T
e X

<

= ;
1
) (
Sampling Principle
A band-limited signal x
a
(t) with bandwidth F
0
can be
reconstructed from its sample values x(n)=x
a
(nT
s
) if the
sampling frequency F
s
=1/T
s
is greater than twice the
bandwidth F
0
of x
a
(t) ,
F
s
>2 F
0
.
Otherwise aliasing would result in x(n). The sampling rate of 2
F
0
for an analog band-limited signal is called the Nyquist rate.
After xa(t) is sampled, the highest anal og frequency that x(n)
represents is Fs/2 Hz (or = )
MATLAB implementation
Let t be the grid interval such that t <= Ts
Can be used as an array to simulate an analog signal
The Fourier transformrelation should also be approximated:


=
m
t m j
G
m
t m j
G a
e m x t t e m x j X ) ( ) ( ) (
) ( ) ( t m x m x
a G
=

Example 1
Let x
a
(t)=e
-1000|t|






+ = =
0
1000
0
1000
) ( ) ( dt e e dt e e dt e t x j X
t j t t j t t j
a a
2
1000
1
002 . 0


+
=
To evaluate X
a
(j) numerically, we have to approximate x
a
(t) by a
finite duration grid sequence x
G
(m)
Using the approximation e-5=0, x
a
(t) can be approximate by a finite
duration signal over -0.005 <= t <= 0.005
Xa(j) = 0 for >= 2(2000)
Hence, choosing
We can obtain xG(m) and then implement in MATLAB
5 5
10 25
) 2000 ( 2
1
10 5

= = t
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.5
1
t in msec.
x
a
(
t
)
Analog S ignal
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
0
0.5
1
1.5
2
F requency in K Hz
X
a
(
j
W
)
*
1
0
0
0
Continuous -time F ourier Trans form
Dt = 0. 00005;
t = - 0. 005: Dt : 0. 005;
xa = exp( - 1000*abs( t ) ) ;
%Cont i nuous- t i me Four i er Tr ansf or m
Wmax = 2*pi *2000;
K = 500; k = 0: 1: K;
W= k*Wmax/ K;
Xa = xa * exp( - j *t ' *W) * Dt ;
Xa = r eal ( Xa) ;
W= [ - f l i pl r ( W) , W( 2: 501) ] ; %Omega f r om- Wmax t o Wmax
Xa = [ f l i pl r ( Xa) , Xa( 2: 501) ] ;
subpl ot ( 1, 1, 1)
subpl ot ( 2, 1, 1) ; pl ot ( t *1000, xa) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
t i t l e( ' Anal og Si gnal ' )
subpl ot ( 2, 1, 2) ; pl ot ( W/ ( 2*pi *1000) , Xa*1000) ;
xl abel ( ' Fr equency i n KHz' ) ; yl abel ( ' Xa( j W) *1000' )
t i t l e( ' Cont i nuous- t i me Four i er Tr ansf or m' )
To reduce the number of computation
we compute X
a
(j) over [0,4000] rad/sec
then duplicate it over [-4000,0] for plotting
purpose
Example 2a
Sample x
a
(t) in example 1 at F
s
= 5000 sam/sec to obtain x
1
(n)
Nyquist rate is 4000 sam/sec. F
s
= 5000 > 4000
No aliasing
%Anal og Si gnal
Dt = 0. 00005;
t = - 0. 005: Dt : 0. 005;
xa = exp( - 1000*abs( t ) ) ;
%Di scr et e- t i me Si gnal
Ts = 0. 0002; n = - 25: 1: 25;
x = exp( - 1000*abs( n*Ts) ) ;
%Di scr et e- t i me Four i er t r ansf or m
K = 500; k = 0: 1: K;
w = pi *k/ K;
X = x * exp( - j *n' *w) ;
X = r eal ( X) ;
w = [ - f l i pl r ( w) , w( 2: K+1) ] ;
X = [ f l i pl r ( X) , X( 2: K+1) ] ;
subpl ot ( 1, 1, 1)
subpl ot ( 2, 1, 1) ; pl ot ( t *1000, xa) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
t i t l e( ' Di scr et e Si gnal ' ) ; hol d on
st em( n*Ts*1000, x) ; hol d of f
subpl ot ( 2, 1, 2) ; pl ot ( w/ pi , X) ;
xl abel ( ' Fr equency i n pi uni t s' ) ; yl abel ( ' X( w) ' )
t i t l e( ' Di scr et e- t i me Four i er Tr ansf or m' )
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.5
1
t in msec.
x
a
(
t
)
Discrete Signal
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
0
5
10
Frequency in pi units
X
(
w
)
Discrete-time Fourier Transform
Example 2b
Sample x
a
(t) in example 1 at F
s
= 1000 sam/sec to obtain x
1
(n)
Nyquist rate is 4000 sam/sec. F
s
= 1000 < 4000
Some aliasing
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.5
1
t in msec.
x
a
(
t
)
Discrete Signal
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
0
1
2
3
Frequency in pi units
X
(
w
)
Discrete-time Fourier Transform
%Anal og Si gnal
Dt = 0. 00005;
t = - 0. 005: Dt : 0. 005;
xa = exp( - 1000*abs( t ) ) ;
%Di scr et e- t i me Si gnal
Ts = 0. 001; n = - 5: 1: 5;
x = exp( - 1000*abs( n*Ts) ) ;
%Di scr et e- t i me Four i er t r ansf or m
K = 500; k = 0: 1: K;
w = pi *k/ K;
X = x * exp( - j *n' *w) ;
X = r eal ( X) ;
w = [ - f l i pl r ( w) , w( 2: K+1) ] ;
X = [ f l i pl r ( X) , X( 2: K+1) ] ;
subpl ot ( 1, 1, 1)
subpl ot ( 2, 1, 1) ; pl ot ( t *1000, xa) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
t i t l e( ' Di scr et e Si gnal ' ) ; hol d on
st em( n*Ts*1000, x) ; hol d of f
subpl ot ( 2, 1, 2) ; pl ot ( w/ pi , X) ;
xl abel ( ' Fr equency i n pi uni t s' ) ; yl abel ( ' X( w) ' )
t i t l e( ' Di scr et e- t i me Four i er Tr ansf or m' )
Shape of X(e
j
) is different from X
a
(j)
Result of adding overlapping replicas
Reconstruction
Impulse train
conversion
Ideal lowpass
filter
) (n x
) (t x
a
L L + + + + + =

+
=
) ( ) 1 ( ) ( ) 0 ( ) ( ) 1 ( ) ( ) (
s s
n
s
T t x t x T t x nT t n x

+
=
=
n
s s a
nT t F n x t x )] ( [ sinc ) ( ) (
sinc(x) = sin(x)/x
Lowpass filter band-limited to the [-Fs/2,Fs/2] band
The ideal interpolation is not practically feasible because the entire
system is noncausal and hence not realizable.
Interpolating formula
Reconstruction of band-limited signal
Practical D/A converters
Zero-order-hold (ZOH) interpolation:
In this interpolation a given sample value is held for the
sample interval until the next sample is received.
It can be obtained by filtering the impulse train through an
interpolating filter of the form


=
+ =
otherwise 0
0 1
) (
) 1 ( ), ( ) (

0
s
s s a
T t
t h
T n n nT n x t x
The resulting signal is a piecewise-constant (staircase) waveform which
requires an appropriately designed analog post-filter for accurate
waveform reconstruction.
ZOH Post-Filter
) (n x
) (t x
a
) (

t x
a
First-order-hold (FOH) interpolation
In this case the adjacent samples are joined
by straight lines.


+
=
otherwise 0
2 1
0 1
) (
1 s s
s
s
s
T t T
T
t
T t
T
t
t h
Cubic-order-hold (COH) interpolation
This approach uses spline interpolation for a smoother, but not
necessarily more accurate, estimate of the analog signal between
samples.
Hence this interpolation does not require an analog post-filter
The smoother reconstruction is obtained by using a set of
piecewise continuous third-order polynomials called cubic splines
Where {
i
(n), 0 <= i <= 3}are polynomial coefficients determined
by using least squares analysis on the sample values
s s
s s s a
T n t nT
nT t n nT t n nT t n n t x
) 1 (
, ) )( ( ) )( ( ) )( ( ) ( ) (
3
3
2
2 1 0
+
+ + + =
Matlab Implementation
N=n1: n2; t =t 1: t 2; Fs=1/ Ts; nTs = n*Ts
Xa = x*si nc( Fs*( ones( l engt h( n) , 1) *t - nTs *ones( 1, l engt h( t ) ) ) )
sinc function which generates the sin(x)/x can be use to
implement interpolation
If {x(n), n1 <= n <= n2}is given, to interpolate x
a
(t) with grid
interval t

+
=
=
n
s s a
nT t F n x t x )] ( [ sinc ) ( ) (
2 1
, )] ( [ sinc ) ( ) (
2
1
t t m t nT t m F n x t m x
n
n n
s s a
=

=
Example 3
From the sample x(n) in example 2a, reconstruct x
a
(t)
x(n) was obtained by sampling x
a
(t) at Ts = 1/Fs = 0.0002 sec.
We will use the grid spacing 0.00005 sec over -0.005 <= t <= 0.005,
which gives x(n) over -25 <= n <= 25
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0. 1
0. 2
0. 3
0. 4
0. 5
0. 6
0. 7
0. 8
0. 9
1
t in ms ec .
x
a
(
t
)
R ec ons truc ted S ignal from x 1(n) us ing s inc func tion
Ts = 0. 0002; Fs = 1/ Ts; n = - 25: 1: 25; nTs = n*Ts;
x = exp( - 1000*abs( nTs) ) ;
%Anal og Si gnal r econst r uct i on
Dt = 0. 00005;
t = - 0. 005: Dt : 0. 005;
xa = x * si nc( Fs*( ones( l engt h( nTs) , 1) *t - nTs' *ones( 1, l engt h( t ) ) ) ) ;
%check
er r or = max( abs( xa - exp( - 1000*abs( t ) ) ) )
%Pl ot s
pl ot ( t *1000, xa) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
st em( n*Ts*1000, x) ; hol d of f
er r or =
0. 0363
Example 4
From the sample x(n) in example 2b, reconstruct x
a
(t)
x(n) was obtained by sampling x
a
(t) at Ts = 1/Fs = 0.001 sec.
We will use the grid spacing 0.00005 sec over -0.005 <= t <= 0.005,
which gives x(n) over -5 <= n <= 5
Ts = 0. 001; Fs = 1/ Ts; n = - 5: 1: 5; nTs = n*Ts;
x = exp( - 1000*abs( nTs) ) ;
%Anal og Si gnal r econst r uct i on
Dt = 0. 00005;
t = - 0. 005: Dt : 0. 005;
xa = x * si nc( Fs*( ones( l engt h( nTs) , 1) *t - nTs' *ones( 1, l engt h( t ) ) ) ) ;
%check
er r or = max( abs( xa - exp( - 1000*abs( t ) ) ) )
%Pl ot s
pl ot ( t *1000, xa) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
st em( n*Ts*1000, x) ; hol d of f
er r or =
0. 1852
-5 -4 -3 -2 -1 0 1 2 3 4 5
-0. 2
0
0. 2
0. 4
0. 6
0. 8
1
1. 2
t in ms ec .
x
a
(
t
)
R ec ons truc ted S ignal from x 2(n) us ing s inc func tion
Example 5a
Reconstruct signal from the samples in example 2 using ZOH
interpolation
It is a crude one and the further processing of analog signal is
neccessary
Ts = 0. 0002; n = - 25: 1: 25; nTs = n*Ts;
x = exp( - 1000*abs( nTs) ) ;
%Anal og Si gnal r econst r uct i on usi ng st ai r s
st ai r s( nTs*1000, x) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
st em( n*Ts*1000, x) ; hol d of f
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
t in ms ec.
x
a
(
t
)
Recons tructed S ignal from x1(n) us ing z ero-order-hold
Example 5a
Reconstruct signal from the samples in example 2 using FOH
interpolation
It appears to be good but a carefully observation near t=0
reveals that the peak is not carefully reproduce
In general, if the sampling frequency is much higher than the
Nyquist rate, FOH provides acceptable reconstruction
Ts = 0. 0002; n = - 25: 1: 25; nTs = n*Ts;
x = exp( - 1000*abs( nTs) ) ;
%Anal og Si gnal r econst r uct i on usi ng pl ot s
pl ot ( nTs*1000, x) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
st em( n*Ts*1000, x) ; hol d of f
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
t in ms ec.
x
a
(
t
)
Recons tructed S ignal from x1(n) us ing firs t-order-hold
Example 6a
Reconstruct the sample in example 2a using spline function
Maximum error is lower due to nonideal interpolation and the
fact that x
a
(t) is nonband-limited
The ideal interpolation suffers more from time-limitedness
The plot is excellent
Ts = 0. 0002; n = - 25: 1: 25; nTs = n*Ts;
x = exp( - 1000*abs( nTs) ) ;
%Anal og Si gnal r econst r uct i on
Dt = 0. 00005;
t = - 0. 005: Dt : 0. 005;
xa = spl i ne( nTs, x, t ) ;
pl ot ( t *1000, xa) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
st em( n*Ts*1000, x) ; hol d of f
%check
er r or = max( abs( xa - exp( - 1000*abs( t ) ) ) )
er r or =
0. 0317
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
t in msec.
x
a
(
t
)
Reconstructed S ignal from x1(n) using cubic spline function
Example 6b
Reconstruct the sample in example 2b using spline function
Maximum error is high and cannot be attributed to the
nonideal interpolation or nonband-limitedness of x
a
(t)
The reconstructed signal differs from the actual one
Ts = 0. 001; n = - 5: 1: 5; nTs = n*Ts;
x = exp( - 1000*abs( nTs) ) ;
%Anal og Si gnal r econst r uct i on
Dt = 0. 00005;
t = - 0. 005: Dt : 0. 005;
xa = spl i ne( nTs, x, t ) ;
%check
er r or = max( abs( xa - exp( - 1000*abs( t ) ) ) )
%Pl ot s
pl ot ( t *1000, xa) ;
xl abel ( ' t i n msec. ' ) ; yl abel ( ' xa( t ) ' )
st em( n*Ts*1000, x) ; hol d of f
er r or =
0. 1679
-5 -4 -3 -2 -1 0 1 2 3 4 5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
t in msec.
x
a
(
t
)
Reconstructed Signal from x2(n) using cubic spline function

You might also like