Multi Rate Signal Processing Decimation and Interpolation-Digital Signal Processing-Lab Manual, Exercises of Digital Signal Processing

This is lab manual for Digital Signal Processing course at COMSATS Institute of Information Technology, provided by Dr. Khalida Jaleel. It includes: Multi-rate, Signal, Processing, Decimation, Interpolation, Continuous, Discrete, Upsampling, Downsampling

Typology: Exercises

2011/2012

Uploaded on 07/06/2012

bhalo
bhalo 🇵🇰

4.6

(8)

22 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EEE 324: Lab #5
COMSATS INSTITUE OF INFORMATION TECHNOLOGY
Digital Signal Processing
MULTI-RATE SIGNAL PROCESSING: DECIMATIOM AND
INTERPOLATION
LAB # 05
Pre-Lab
Sampling:
Sampling is the process of representing a continuous signal with a sequence of discrete
data values. In practice, sampling is performed by applying a continuous signal to an
analog-to-digital (A/D) converter whose output is a series of digital values
Sampling can be viewed theoretically as multiplying the original signal with a train of
pulses with unit amplitude. This leaves the original signal with information at discrete
points with magnitude of signal present in the original signal at that position. This is
illustrated in the figure below.
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Multi Rate Signal Processing Decimation and Interpolation-Digital Signal Processing-Lab Manual and more Exercises Digital Signal Processing in PDF only on Docsity!

COMSATS INSTITUE OF INFORMATION TECHNOLOGY

Digital Signal Processing

MULTI-RATE SIGNAL PROCESSING: DECIMATIOM AND

INTERPOLATION

LAB # 05

Pre-Lab

Sampling:

Sampling is the process of representing a continuous signal with a sequence of discrete data values. In practice, sampling is performed by applying a continuous signal to an analog-to-digital (A/D) converter whose output is a series of digital values

Sampling can be viewed theoretically as multiplying the original signal with a train of pulses with unit amplitude. This leaves the original signal with information at discrete points with magnitude of signal present in the original signal at that position. This is illustrated in the figure below.

Downsampling (Decimation):

Decimation is a technique for reducing the number of samples in a discrete-time signal. The operation of downsampling by factor M describes the process of keeping every Mth sample and discarding the rest. This is denoted by " ↓M ↓ M " in block diagrams

The decimation process filters the input data with a low pass filter and then resamples the resulting smoothed signal at a lower rate.

Decimation is the process of filtering and downsampling a signal to decrease its effective sampling rate, as illustrated in figure. The filtering is employed to prevent aliasing that might otherwise result from downsampling.

Why Decimate?

The most immediate reason to decimate is simply to reduce the sampling rate at the output of one system so a system operating at a lower sampling rate can input the signal. But a much more common motivation for decimation is to reduce the cost of processing: the calculation and/or memory required to implement a DSP system generally is proportional to the sampling rate, so the use of a lower sampling rate usually results in a cheaper implementation.

Example:

between every sample of the input signal. This is denoted by “↑L ↑ L “in block diagrams, as in figure.

The process of increasing the sampling rate is called interpolation. Interpolation is upsampling followed by appropriate filtering. obtained by interpolating is generally represented as:

The simplest method to interpolate by a factor of L is to add L-1 zeros in between the samples multiply the amplitude by L and filter the generated signal, with a so-called anti- imaging low pass filter at the high sampling frequency.

Different Methods of Interpolation:

1) Nearest neighbor interpolation:

This method sets the value of an interpolated point to the value of the nearest existing data point.

2) Linear interpolation:

This method fits a different linear function between each pair of existing data points, and returns the value of the relevant function at the points specified.

3) Cubic interpolation:

This method fits a different cubic function between each pair of existing data points

Purpose of Interpolation: These processes are required to make the sampling rate of the signal compatible with the bandwidth of the signal processing system. Integer factor interpolation and decimation algorithms may be implemented using efficient FIR filters.

Example:

Code for Interpolation:

%%%%%%%%% Sequence generation %%%%%%%%%% n = 0:20; x = (1.5).^n; x1 = [zeros(1,2000) x] x2 = fliplr(x1); sequence = [x1 x2]; figure(1); subplot(311); stem(sequence); fft_of_sequence = abs(fft(sequence,131072)); x1 = [0:1:131071]./(65536); figure(2); subplot(311); plot(x1,fft_of_sequence);

%%%%%%%%%% Up sampling by a factor of L %%%%%%%%% Interpol_sequence = zeros(1,L*(length(sequence))); j = 1; for i = 1:L:length(interpol_sequence) Interpol_sequence(1,i) = sequence(1,j); j=j+1; end figure(1); subplot(312);

Figure 2

Learning objectives

By the end of this lab session, students will be able to know about:

  1. Sampling
  2. Downsampling (Decimation)
  3. Upsampling (Interpolation).
  4. Filtering within Sampling

MATLAB COMMANDS:

1) Decimate:

  • It reduces the sample rate.

y = decimate(x, r) y = decimate(x,r,n) y = decimate(x,r,'fir')

  • y = decimate(x, r) reduces the sample rate of x by a factor r.
  • The decimated vector y is r times shorter in length than the input vector x.
  • By default, decimate employs an eighth-order lowpass Chebyshev Type I filter.
  • It filters the input sequence in both the forward and reverse directions to remove all phase distortion, effectively doubling the filter order.
  • y = decimate(x,r,n) uses an order n Chebyshev filter. Orders above 13 are not recommended because of numerical instability.
  • y = decimate(x,r,'fir') uses a 30-point FIR filter, instead of the Chebyshev IIR filter.
  • Here decimate filters the input sequence in only one direction. This technique conserves memory and is useful for working with long sequences.

2) Interp:

- It increases the sampling rate.

y = interp(x, r) y = interp(x, r, l, alpha) [y, b] = interp(x, r, l, alpha)

  • y = interp(x, r) increases the sampling rate of x by a factor of r. The interpolated vector y is r times longer than the original input x.
  • y = interp(x, r, l, alpha) specifies l (filter length) and alpha (cut-off frequency). The default value for l is 4 and the default value for alpha is 0.5.
    • [y,b] = interp(x,r,l,alpha) returns vector b containing the filter coefficients used for the interpolation.

3) Fliplr:

B = fliplr (A)

-It returns A with columns flipped in the left-right direction, that is, about a vertical axis.

  • If A is a row vector, then fliplr (A) returns a vector of the same length with the order of its elements reversed.
  • If A is a column vector, then fliplr (A) simply returns A.

In-Lab Tasks

Task-1:

a) Generate a sinusoid of frequency f 0 = 3kHz and sampling frequency fs=8kHz using

x[n] = sin((2 * pi * f 0 / fs))*n) where n = 0:1: 15999.

Stem the Fourier transform of x[n] using fft command (zero-frequency component should be at center.

b) Now decimate it by M = 2 & if you see the Fourier transform of this sequence, it will show a sinusoid at 1kHz which is an aliased component. c) Now pass x[n] through an anti-aliasing filter of wc = pi/2 and see the spectrum. You will see that the signal contains no frequency components as wc = pi/2 =