Thursday, September 5, 2013

VERIFICATION OF INTERPOLATION AND DECIMATION USING MATLAB

PROGRAM TO VERIFY DECIMATION AND INTERPOLATION OF A GIVEN SEQUENCE

Introduction

% Software Used: Matlab Version 7.6.0.324
% Submitted by : GG

Initial Command (Closing and Clearing)

clc;                % clears the command window
close all;          % closes all the previously open window
clear all;          % clears previously stored values

Generating Input Sequence

fm = 10;            %  input signal frequency
Fs = 140;           %  sampling frequency
t = 0:1/Fs:0.5;     % time range for the input sequence
x = sin(2*pi*fm*t); % input sinusoidal signal
figure(1)
subplot(4,1,1)
stem(x);                    % Discrete plot of the input sequence,...
                            ... where x-axis corresponds to the number of samples
xlabel('No. of samples');   % labelling x-axis
ylabel('Amplitude');        % labelling y-axis
title('input discrete sinusoidal sequence'); % giving title to the plot





% Inference: A sinsoidal input signal was generated with the signal
% frequenccy of 10 Hz and was again sampled using the sampling frequency of
% 140 Hz which is well above to satisfy the nyquist criterion.So, we
% obtained 72 samples from 0 to 0.5 sec when sampled at 140 Hz. The
% obtained sinusoidal sequence was subjected to discrete plot using
% stem plot option which plots the sampled signal amplitude with respect
% to the number of samples. The first plot of the figure corresponds to
% the generated sinusoidal sequence


Decimation of the Input Sequence

M = 2;              % factor by which the input sequence is decimated
xd = decimate(x,M); % resamples the sample in x with a rate (1/M) times the original rate
subplot(4,1,2)
stem(xd)            % Discrete plot of the input sequence,...
                    ... where x-axis corresponds to the number of samples
xlabel('No. of samples'); % labelling x-axis
ylabel('Amplitude');      % labelling y-axis
title('Decimated Sinusoidal Sequence'); % giving title to the plot


% Inference: The obtained sinusoidal sequence was subjected for the
% decimation by the factor M = 2. The process of decimation involves
% resampling the sequence in low data rate after the process of low pass
% filtering.Since the given sequence is decimated by the factor 2,
% the resultant sequence after the decimation should have exactly
% half the number of samples than that of the original sequence.
% It is clearly seen in the plot that the decimated sequence has
% 36 samples in comarison to 72 of the original sample. Hence
% the decimation of a sequence is verified.


Interolation of the Input Sequence

L = 2;              % factor by which the input sequence is interpolated
xI = interp(x,L);   % resamples the sample in x with a rate L times the original rate
subplot(4,1,3);
stem(xI);           % Discrete plot of the input sequence,...
                    ... where x-axis corresponds to the number of samples
xlabel('No. of  samples');  % laeblling x-axis
ylabel('Amplitude');        % labelling y-axis
title('Interpolated Sinuoidal Sequence')   % giving title to the plot




% Inference: The obtained sinusoidal sequence was also subjected for the
% interpolation by the factor L = 2. The Process of interpolation involves
% resampling the sequence at higher sampling rate using low pass filter.
% Since the interpolation factor is 2, the samples in interpolated signal
% must double than that of the original signal and it can be verfied from
% the plots obtained. Hence the interpolation is also verfied.


Interpolation of the Decimated Signal

L = 2;              % coefficient by which the singal is interpolated
xI = interp(xd,L);  % resamples the sample in x with a rate L times the original rate
subplot(4,1,4)
stem(xI);           % Discrete plot of the input sequence,...
                    ... where x-axis corresponds to the number of samples
xlabel('No. of  samples'); % labelling x-axis
ylabel('Amplitude');       % labelling y-axis
title('Original Signal Obtained After Interpolating the Decimated Signal'); % giving title to the graph

% Inference: When a sequence is decimated by a certain factor and then
% again subjected to the interpolation by the same factor, original
% sequence can be recovered. This has been verified by the 4th plot
% on the figure, which is the interpolation of the decimated signal in the
% 2nd plot. The 4th plot obtained is similar to the input sequence. So,
% interpolating a decimated signal or decimating a interpolated signal
% gives the original signal.





No comments: