





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 9
This page cannot be seen from the preview
Don't miss anything!






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
By the end of this lab session, students will be able to know about:
MATLAB COMMANDS:
1) Decimate:
y = decimate(x, r) y = decimate(x,r,n) y = decimate(x,r,'fir')
2) Interp:
- It increases the sampling rate.
y = interp(x, r) y = interp(x, r, l, alpha) [y, b] = interp(x, r, l, alpha)
3) Fliplr:
B = fliplr (A)
-It returns A with columns flipped in the left-right direction, that is, about a vertical axis.
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 =