Exp Sampling
Exp Sampling
KST, 4/2002
Introduction
This note describes some simple experiments in MATLAB to illustrate the sampling and reconstruction
processes, and the implementation of filtering concepts.
The required theoretical background is primarily continuous-time systems, Fourier transform and a basic
understanding of their discrete-time counterparts.
For the illustration of the theoretical principles, the various signals are compared in time and frequency
domain. The corresponding sounds are also reproduced with MATLAB’s “sound” function to provide a
tangible understanding of the concepts.
(MATLAB commands appear in Courier font; the commands are MATLAB Version 6.1, or Release 12)
Experiment 1
Here we create a sinusoid with frequency 1 kHz and listen to the sound. We use a high sampling frequency
of 44.1 kHz that represents a fairly good approximation of the continuous time signal.
Derivations: Continuous Fourier transform interpretation of the Discrete Fourier Transform (DFT) and
Fast Fourier Transform (FFT).
The DFT is a discrete-time transform defined for a finite sequence of N numbers, as follows.
N −1 2π
−j kn
X ( k ) = ∑ x ( n )e N
n =0
The term FFT is used to signify a specific method to compute the DFT in an efficient manner. While a
transform in its own right, the DFT/FFT can be interpreted in terms of the CT-Fourier transform for a
sampled signal x(t). Let us consider a signal x(t), sampled at the time instants nT, n = 0,1,…N-1, and
suppose that the signal is 0 outside the sampled interval [0, (N-1)T]. The Fourier transform of this signal is
∞ ( N −1)T
∫ x(t )e ∫ x(t )e
− jwt − jwt
X ( jw) = dt = dt
−∞ 0
First, in a naïve approach, let us approximate the integral by an Euler discretization, whereby the integrand
is taken as piecewise constant.
( N −1)T N −1
∫ x(t )e dt ≅ ∑ x(nT )e T
− jwt − jwnT
X ( jw) =
0 n =0
2π
Let us consider now a sampled version of the Fourier transform at the frequencies w = kw0 = k ,
TN
where k=0,1,…,N-1. Then,
N −1 k 2π N −1 2π
−j nT −j kn
X ( jkw0 ) ≅ ∑ x(nT )e NT
T = T ∑ x(nT )e N
n=0 n=0
Thus,
F{x} |w= kw0 ≅ FFT {x(nT )}T
This approximation is valid as long as the integrand approximation by a piecewise constant function is
reasonable. This implies that k must be small and x(t) should not change significantly inside any sampling
interval of length T.
= ∑ x(nT )e − jwnT
2π
Again, evaluating this transform at a discrete set of frequencies w = kw0 = k , we get
TN
2π
2π −j kn
X s jk = ∑ x(nT )e N = FFT {x(nT )}
TN n
In other words, the FFT of the sampled signal is equal to the Fourier transform of the sampled signal
evaluated at the frequencies kw0, in the interval [0, ws]. This means that the FFT will be symmetric about
the point ws/2. It will also be approximately equal to X(jw)/T, (at the corresponding discrete frequencies in
the interval [0, ws/2]) as long as any aliasing effects are small.
(Note: The symmetry of the FFT is the reason why only the first half of the FFT points are shown in the
plots.)
Experiment 2
In this experiment we sample the same sinusoid (1 kHz) at a lower sampling rate to study the aliasing
effects.
Experiment 3
Here we use different digital filters to “interpolate” the values of the low rate signal and convert it to a high
rate signal. This does not overcome any aliasing effects that occurred at sampling but improves the
reproduction by reducing the undesirable properties of the low rate ZOH. (It does require a better D/A
converter!) In the following table we concentrate on the implementation of a digital filter by approximating
the impulse response of an ideal low-pass.
Notes: Given a discrete-time signal y(n), the upsampled signal (by a) is defined as the signal z(n) such that
y (k ) if n = ak
z (n) =
0 otherwise
Equivalently, we may think of z(n) as the signal produced by sampling the continuous time signal y(t) with
the impulse train pu (t ) = ∑ bn δ (t − n Ta ) , where bn = 1, if n/a is an integer, and 0 otherwise.
Clearly, the upsampling impulse train is identical with the original delta train p (t ) = ∑ δ (t − nT ) and,
therefore, the continuous-time sampled signals y(t)p(t) and y(t)pu(t) are the same, and have the same Fourier
transforms. The latter, however, has a smaller sampling time (larger sampling frequency), implying that the
FFT of the discrete-time sequence will contain several replicas of F{y}. The upsampling process does not
create any new information about the time signal but allows for the implementation of better low-pass
filters in discrete time.
Experiment 4
Equalizers are often used in audio equipment to amplify (or attenuate) frequency bands in an effort to
improve the quality of reproduction of the original signal. Their objective is to cancel (or invert) the audio
signal distortion caused by equipment limitations (amplifier, speaker, media) or the environment where the
signal is reproduced.
In this experiment we use digital low-pass filters to implement a “frequency equalizer.” The test signal is
the standard Windows sound “Tada.” The attached Matlab program loads the sound and filters it with three
different low-pass filters. Then, by taking different linear combinations of the resulting signals we can
amplify or attenuate the energy of the signal in the desired frequency band(s).