Sei sulla pagina 1di 8

AIM:

Write a MATLAB Script to perform sampling rate conversion for any


given arbitrary sequence (D.T) or signal (C.T) by interpolation, decimation,
upsampling, downsampling and resampling (i.e. fractional value)
.
APPARATUS REQUIRED:
PC, MATLAB software
THEORY:
SAMPLING PROCESS:
It is a process by which a continuous time signal is converted into
discrete time signal. X[n] is the discrete time signal obtained by taking samples
of the analog signal x(t) every T seconds, where T is the sampling period.
X[n] = x (t) x p (t)
Where p(t) is impulse train;

T period of the train

SAMPLING THEOREM:
It states that the band limited signal x(t) having no frequency components
above Fmax Hz is specified by the samples that are taken at a uniform rate greater
than 2 Fmax Hz (Nyquist rate), or the frequency equal to twice the highest
frequency of x(t).
Fs 2 Fmax
SAMPLING RATE CONVERSION:
Sampling rate conversion is employed to generate a new sequence with a
sampling rate higher or lower than that of a given sequence. If x[n] is a
sequence with a sampling rate of F Hz and it is used to generate another
sequence y[n] with desired
alteration is given by,
F/F = R

sampling rate F Hz, then the sampling rate

If R > 1, the process is called interpolation and results in a sequence with


higher sampling rate. If R< 1, the process is called decimation and results in a
sequence with lower sampling rate.
DOWNSAMPLE AND DECIMATION:
Down sampling operation by an integer factor M (M>1) on a sequence
x[n]

consists of keeping every Mth sample of x[n] and removing M-1 in

between samples, generating an output sequence y[n] according to the relation


y [n] = x[nM]
y [n] sampling rate is 1/M that of x[n]
If we reduce the sampling rate, the resulting signal will be an aliased version of
x[n]. To avoid aliasing, the bandwidth of x[n] must be reduced to F max =Fx/2
or max = /M. The input sequence is passed through LPF or an antialiasing
filter before down sampling.
x [n]

ANTIALIASING
FILTER H (Z)

y[n]

UPSAMPLE AND INTERPOLATION:


Upsampling by an integer factor L (L > 1) on a sequence x[n] will insert
(L1) equidistant samples between an output sequence y[n] according to the
relation
x[n/L],
y[n] =

0,

n = 0, 1, 2 .
otherwise

The sampling rate of y[n] is L times that of x[n]. The unwanted images in the
spectra of sampled signal must be removed by a LPF called anti-imaging filter.
The input sequence is passed through an anti-imaging filter after up sampling.
x[n]

ANTI IMAGING FILTER H y[n]


(Z)

SAMPLING RATE CONVERSION BY A RATIONAL FACTOR I/O:


We achieve this conversion, by first performing interpolation by the
factor I and then decimating the output of interpolator by the factor D,
interpolation has to be performed before decimation to obtain the new rational
sampling rate.
x[n]

ANTI IMAGING FILTER ANTI ALIASING FILTERDOWN SAMPLER y[n]


UPSAMPLER

LIBRARY FUNCTIONS:
resample: Changes sampling rate by any rational factor.
y = resample (x,p,q) resamples the sequence in vector x at p/q times the original
sampling rate, using a polyphase filter implementation. p and q must be positive
integers. The length of y is equal to ceil (length(x)*p/q).
interp:

Increases sampling rate by an integer factor

(interpolation)
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. interp performs low pass
interpolation by inserting zeros into the original sequence and then applying a
special low pass filter.
upsample: Increases the sampling rate of the input signal
y = upsample(x,n) increases the sampling rate of x by inserting n-1 zeros
between samples. The upsampled y has length(x)*n samples
decimate:

Decreases

the

sampling

rate

for

sequence

(decimation).
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 low pass 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.
downsample: Decreases the sampling rate of the input signal
y = downsample(x,n) decreases the sampling rate of x by keeping every n th
sample starting with the first sample. The downsampled y has length(x)/n
samples
ALGORITHM/PROCEDURE:
1. Generate a sinusoidal waveform
2. Using the appropriate library function for interpolation ,decimation
,upsampling ,
downsampling and resampling, perform sampling rate conversion for the
sinusoidal waveform
3. Find the spectrum of all the signals and compare them in frequency
domain.
4. Display the resultant waveforms

Source code :
clc;
clear all;
close all;
%continuous sinusoidal signal
a=input('Enter the amplitude:');
f=input('Enter the Timeperiod:');
t=-10:1:20;
x=a*sin(2*pi*f*t);
subplot(2,3,1);
plot(t,x);
xlabel('time');
ylabel('Amplitude');

title('Sinusoidal signal');
%decimating the signal
d=input('Enter the value by which the signal is to be decimated:');
y1=decimate(x,d);
subplot(2,3,2);
stem(y1);
xlabel('time');
ylabel('Amplitude');
title('Decimated signal');
%interpolating the signal
i=input('Enter the value by which the signal is to be interpolated:');
y2=interp(x,i);
subplot(2,3,3);
stem(y2);
xlabel('time');
ylabel('Amplitude');
title('Interpolated signal');
%resampling the signal
y3=resample(x,3,2);
subplot(2,3,4);
stem(y3);
xlabel('time');
ylabel('Amplitude');
title('Resampled signal');
%downsampling the signal
y4=downsample(x,2);
subplot(2,3,5);
stem(y4);
xlabel('time');
ylabel('Amplitude');
title('Downsampled signal');
%upsampling the signal
y5=upsample(x,3);
subplot(2,3,6);
stem(y5);
xlabel('time');
ylabel('Amplitude');
title('Upsampled signal');

Output :

RESULT:
The program written using library functions and the sampling rate
conversion process is studied.

FLOWCHART:

START

ENTER THE INPUT SEQUENCE x[n]


& SYSTEM RESPONSE h[n]

PERFORM LINEAR AND CIRCULAR CONVOLUTION IN TIME DOMAIN

PLOT THE WAVEFORMS AND ERROR

STOP

Potrebbero piacerti anche