Sunteți pe pagina 1din 4

1

ELEC-422 - Communications Signal Processing


Matlab Assignment from Week 6. Optional Extra Credit (4% of final mark)
Due March 28, 2011.
MULTIRATE DIGITAL SIGNAL PROCESSING

I. INTRODUCTION

This assignment investigates singal interpolation and decimation experimentally. The


first three parts involve experimenting with a given data sequence, while Part 4
involves use of audio input and output and uses MATLAB’s sound and auread
functions.

II. BANDLIMITED INTERPOLATION

Figure 1 depicts a system for interpolating a signal by an integer factor I as discussed in


class.

x(n) xe(n) Low-pass filter xi(n).


I Gain=I, cutoff=π/I

Figure 1. Interpolation.

The low-pass filter interpolates between the nonzero values of x =xe(n) to generate the
interpolated or ‘upsampled’ signal xi(n). When the low-pass filter is ideal, the
interpolation is referred to as ideal bandlimited interpolation.

Accurate bandlimited interpolation requires a carefully designed high-order low-pass


filter. Two simple and very approximate procedures which are often used instead are
zero-order hold and linear interpolation. For zero-order hold interpolation, each value
of x(n) is repeated I times:

⎡ x e (0) n = 0,1,...,I −1

x (I) n = I,I + 1,...,2I −1
x i (n) = ⎢ e
⎢ x e (2I) n = 2L,2L + 1,...

⎣ 
This can be accomplished by convolving xe(n) with impulse response sequence
hzoh (n)= δ (n) + δ (n −1) + ...+ δ (n − (I −1))

Zero-order hold interpolation is often used in A/D converters, resulting in analog


“staircase” waveforms (e.g., each digital sample is converted to a voltage, and that
voltage is “held” for the duration of the sampling period).

Linear interpolation can be accomplished by using a system with impulse response


2

⎡1− | n | /I | n |≤ I −1
hlin (n) = ⎢
⎣ 0 otherwise

Unlike the zero-order hold interpolator, the above linear interpolator is noncausal. The
ideal bandlimited interpolator also has a noncausal infinite-length impulse response:

⎡ sin(πn /I)
n≠0
hideal (n) = ⎢ πn /I
⎢⎣ 1 n=0

We next evaluate the performance the interpolation filters. To perform the sampling
rate expansion, the use the MATLAB function upsample to take a sequence x(n) and an
integer I as input, and returns a zero-filled version of x(n) (with I-1 zeros between each
sample):

1. Enter the impulse responses of the zero-order hold and linear interpolators for I=5.
Note that the linear interpolator is a noncausal filter. Since MATLAB does not recognize
negative indices, you must enter a causal version, and then “time advance” the result by
relabelling the time axis appropriately. Plot the magnitude frequency response of the
zero-order hold and linear interpolation filters on the same graph. Which is a better
approximation to the ideal bandlimited interpolator?

2. Using the MATLAB functions upsample and filter, implement the interpolation
system of Figure 1 with a value of I=5. Use both zero-order hold and linear
interpolation filters. For input to the system, use the sequence
⎡ sin(2πn /50) + 0.6sin(9πn /50) 0 ≤ n ≤ 199
x(n) = ⎢ (1)
⎣ 0 otherwise

Plot the output sequences on the same time axis. In establishing the time axis of the plot,
be sure to take into account that the linearly interpolated sequence is noncausal. (Note:
you may want to use the stem function for plotting discrete-time data).

3. Use the Matlab function interp to perform interpolation using an image filter. This
more closely approximates the ideal bandlimited interpolator than either the linear or
the zero-order hold interpolator. Plot the output sequence on the same time axis as the
original sequence (after aligning the axes to take into account filter delay).

4. Now perform a quantitative comparison of the performance of the two interpolators:


zero-order hold and linear. A measure of the average interpolation error is given by
n2
1
e = ∑
n2 − n1 + 1 n = n
(xi (n) − x ideal (n)) 2
1

where xi(n) is the result of using one of the three interpolation filters, xideal(n) is the
bandlimited interpolation using the Matlab interp function. Choose parameters n1
3

and n2 so as to avoid transient portions of the data. What are suitable choices for n1 and
n2 ?

III. DECIMATION

1. Plot the signal in Eqn. (1), both as a continuous function and as discrete samples.
Note that you have more than 10 samples per cycle at the higher frequency. Identify the
cycles by eye.

To decimate signals, use the MATLAB function, downsample, which takes a sequence
x(n) and an integer D as input, and returns a decimated version of x(n):

2. Decimate the signal in Eqn. (1) by a factor of 4. Try to identify which frequencies are
present. To overcome the problem of not enough samples per cycle, use the bandlimited
interpolation from Part II to reproduce the decimated signal at the original higher rate
to identify the frequency components.

3. Repeat Step 2, but this time use a 6:1 decimation factor. Again, estimate (visually) the
frequencies present in the sampled signal by interpolating back up to the original rate.
Explain why the interpolated signal differs from the original.

4. Decimate the signal as in Step 3, but prior to decimation, low-pass filter the input
sequence using a cutoff frequency at slightly below one-half the final sampling rate to
allow a filter transition width. Design any appropriate low-pass filter for this purpose.
This low-pass filter serves as an anti-aliasing filter. Compare the decimated output to
both the original input signal and the output of the anti-aliasing low-pass filter.

IV. MULTIRATE PROCESSING OF DIGITAL AUDIO

1. Obtain at least one digital audio file from the Elec-422 website or from elsewhere. The
digitized audio data can be input into MATLAB via the MATLAB function auread.
Make sure to place the audio file name in single quotations and omit the .au extension.
Audio files can be played using the function ‘sound’. You can use optional output
parameters of auread to determine the input sampling rate and file size. (The file
warning.au can be downloaded.)

2. Decimate the audio by a factor of 2. Use the MATLAB function sound for playback.
Try to do this with and without a pre-aliasing filter. Comment on the quality of the
resultant speech in both cases.

3. Repeat Step 2 but this time use a decimation factor of 4 instead of 2. Modify your pre-
aliasing filter cutoff accordingly.

4. Plot the magnitude frequency spectrum of the original speech signal and use it to try
to explain your observations recorded in parts 2 and 3.
4

5. (optional, but this only takes a minute!) Using the Matlab function resample, try
changing the sampling rate of the input signal by the factor 4/5. Listen to the result and
record your observations.

S-ar putea să vă placă și