0% found this document useful (0 votes)
11 views

DSP Notes

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

DSP Notes

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Experiment –1

AIM: Verification of sampling theorem

OBJECTIVE: To verify sampling theorem for Nyquist rate, Under sampling and Over
sampling condition in both time and frequency domain using MATLAB.

THEORY:

Sampling: Is the process of converting a continuous time signal into a discrete time signal.
It is the first step in conversion from analog signal to digital signal.

Sampling theorem: Sampling theorem states that “Exact reconstruction of a continuous


time base-band signal from its samples is possible, if the signal is band-limited and the
sampling frequency is greater than twice the signal bandwidth”.i.e. fs> 2W, where W is the
signal bandwidth.

Nyquist Rate Sampling: The Nyquist rate is the minimum sampling rate required to avoid
aliasing, equal to the highest modulating frequency contained within the signal. In other
words, Nyquist rate is equal to two sided bandwidth of the signal (Upper and lower
sidebands) i.e., fs = 2W.To avoid aliasing, the sampling rate must exceed the Nyquist rate.
i.e.fs>fN, where fN =2W.

ALGORITHM:
1. Select the frequency of analog signal f Hz
2. To generate sine wave of f Hz define a closely spaced time vector
3. Generate the sinusoid and plot the signal

4. Select the sampling frequency fs= 10f samples/sec. Generate a suitable time scale for
this sampling signal
5. Sample the analog signal at the instant specified by n.
6. Modify the time vector n used for discrete simulation
7. Reconstruct the analog signal from its discrete samples
8. Compare the analog and reconstructed signal
9. Repeat the values experiment for different values of f and verify reconstructed and
analog signal

Program:

clc;
clear all;
%define analog signal for comparison t=-100:01:100;
fm=0.02;
x=cos(2*pi*t*fm);
subplot(2,2,1);
plot(t,x);
xlabel('time in sec'); ylabel('x(t)');
title('continuous time signal');
%simulate condition for undersamplingi.e.,fs1<2*fm
fs1=0.02;
n=-2:2;
x1=cos(2*pi*fm*n/fs1);
subplot(2,2,2);
stem(n,x1); hold on
subplot(2,2,2);
plot(n,x1,':');
title('discrete time signal x(n) with fs<2fm');
xlabel('n');
ylabel('x(n)');
%condition for Nyquist plot
fs2=0.04;
n1=-4:4;
x2=cos(2*pi*fm*n1/fs2);
subplot(2,2,3);
stem(n1,x2);
hold on
subplot(2,2,3);
plot(n1,x2,':');
title('discrete time signal x(n) with fs>2fm');
xlabel('n');
ylabel('x(n)');
%condition for oversampling n2=-
50:50;
fs3=0.5;
x3=cos(2*pi*fm*n2/fs3);
subplot(2,2,4);
stem(n2,x3);
hold on
subplot(2,2,4);
plot(n2,x3,':');
xlabel('n');
ylabel('x(n)');
title('discrete time signal x(n) with fs=2fm');

Results:
Discussions on results

EXPERIMENT NO-2 : Linear CONVOLUTION

Page 4
AIM: To implement linear convolution of two given sequences

OBJECTIVE:
1. To find linear convolution of right sided sequence using inbuilt MATLAB function
“CONV” and its theoretical method to verify the result
2. To find linear convolution of both sided sequence using inbuilt MATLAB function
“CONV” and its theoretical method to verify the result
3. To find linear convolution of a given sequences using circular convolution.

THEORY: Convolution is an integral concatenation of two signals. It has many applications


in numerous areas of signal processing. The most popular application is the determination
of the output signal of a linear time-invariant system by convolving the input signal with the
impulse response of the system. Note that convolving two signals is equivalent to
multiplying the Fourier transform of the two signals. In linear systems, convolution is used
to describe the relationship between three signals of interest: the input signal, the impulse
response, and the output signal. In linear convolution length of output sequence
is,length(y(n)) = length(x(n)) + length(h(n)) – 1

Mathematical Formula:

The linear convolution of two continuous time signals x(t) and h(t) is defined by

For discrete time signals x(n) and h(n), is defined by

Where x(n) is the input signal and h(n) is the impulse response of the system.
ALGORITHM:
1. Read the input sequence, x[n] and plot.
2. Read the impulse response of the system, h[n] and plot
3. Convolve the two sequences using conv command and plot the results.

Page 5
PROGRAM:LINEAR CONVOLUTION OF RIGHT SIDED SEQUENCES
clc; % clear screen
clear all; % clear workspace
close all; % close all figure windows
x1 = input('enter the first sequence x1(n) = '); % define first sequence
x2 = input('enter the second sequence x2(n) = '); % define second sequence
y = conv(x1,x2); % convolute first and second
sequences disp('Linear convolution of x1 and x2 is = ');
disp(y); % display the output
%graphical display
subplot(2,2,1); % divide the display screen in four sections and choose the first one to
display stem(x1); % plot the first sequence
xlabel('n'); % label x axis
ylabel('x1(n)'); % label y axis
title('plot of x1(n)'); % graph title

subplot(2,2,2);% divide the display screen in four sections and choose the first second
to display
stem(x2); % plot the second sequence
xlabel('n'); % label x axis
ylabel('x2(n)'); % label y axis
title('plot of x2'); % graph title
subplot(2,1,2);% divide the display screen in four sections and choose the first second
to display
stem(y); % plot the output sequence
xlabel('n'); % label x axis
ylabel('y(n)'); % label y axis
title('convolution output'); % graph title

OUTPUT:

enter the first sequence x1(n) = [1 5 10 20]


enter the second sequence x2(n) = [5 10]

Page 6
Linear convolution of x1 and x2 is = 5 35 100 200 200

PROGRAM: LINEAR CONVOLUTION OF BOTH SIDED SEQUENCES


clc; % clear screen
clear all; % clear work space
close all; % close all figure windows
x1 = input('enter the first sequence x1(n) = '); % define first sequence
x2 = input('enter the second sequence x2(n) = '); % define second
sequence
n1 = -2:2; % time axis for first sequence
n2 = -1:3; % time axis for second sequence
ybegin = n1(1)+n2(1); % calculate the first point of x axis of
output yend = n1(length(x1)) + n2(length(x2)); % calculate the end point of x axis
of output ny = [ybegin : yend]; % define x axis for output
y = conv(x1,x2); % convolute the first and second
sequence disp('Linear convolution of x1 and x2 is = ');
disp(y); % display the output
%graphical display
subplot(2,2,1);% divide the display screen in four sections and choose the first second
to display
stem(n1,x1); % plot the first sequence
xlabel('n'); % label x axis

ylabel('x1(n)'); % label y axis


title('plot of x1'); % graph title
subplot(2,2,2);% divide the display screen in four sections and choose the second to
display stem(n2,x2); % plot the second sequence
xlabel('n'); % label x axis
ylabel('x2(n)'); % label y axis
title('plot of x2'); % graph title
subplot(2,1,2);% divide the display screen in four sections and choose the second to
display stem(ny,y); % plot the second sequence

Page 7
xlabel('n'); % label x axis
ylabel('y(n)'); % label y axis
title('convolution output'); % graph title

OUTPUT:
enter the first sequence x1(n) = [1 2 3 2 1 3 4]
enter the second sequence x2(n) = [2 -3 4 -1 0 1]
Linear convolution of x1 and x2 is =
2 1 4 2 6 9 3 2 15 -3 3 4

PROGRAM: LINEAR CONVOLUTION USING CIRCULAR CONVOLUTION


clc; % clear screen
clear all; % clear work space
close all; % close all figure windows
xn = input('enter the first sequence x(n) = ');
hn = input('enter the second sequence h(n) =
');
l1 = length(xn); % length of first sequence
l2 = length(hn); % length of second sequence
N = l1+l2-1; % length of output
xn = [xn,zeros(1,l2-1)]; % add zeros to make length of xn and hn equal
hn = [hn,zeros(1,l1-1)]; % add zeros to make length of xn and hn equal

for n=0:N-1; %function for linear convolution in time


domain y(n+1) = 0;
for k=0:N-1;
i = mod((n-
k),N); if i<0
i=
i+N;
end
y(n+1) = y(n+1)+hn(k+1)*xn(i+1);
end

Page 8
end
disp('Linear Convolution using Circular Convolution = ');
disp(y); % display
output
subplot(2,2,1); %Graphical display of first input
sequence stem(xn);
xlabel('n');
ylabel('x(n)');
title('Plot of x1(n)');
subplot(2,2,2); %Graphical display of second input
sequence stem(hn);
xlabel('n');

ylabel('(h(n)');
title('Plot of x2(n)');
subplot(2,2,3); %Graphical display of output sequence stem(y);

xlabel('n');
ylabel('y(n)');
title('Linear Convolution Output');

OUTPUT:

enter the first sequence x(n) = [1 2 3]


enter the second sequence h(n) = [4 5 2]
Linear Convolution using Circular Convolution
= 4 13 24 19 6

OUTCOME:Linear convolution of the sequences is found and the results are verified in
MATLAB.

Page 9
EXPERIMENT NO- 3 :- CIRCULAR CONVOLUTION
AIM: Circular convolution of two given sequences

OBJECTIVE: To implement circular convolution of given sequences in time domain


using MATLAB and to verify the result theoretically.

THEORY:Let x1(n) and x2(n) are finite duration sequences both of length N with
DFT’s X1(k) and X2(k). Convolution of two given sequences x1(n) and x2(n) is given

by the equation,
x3(n) = IDFT[X3(k)]where X3(k) = X1(k) X2(k)

ALGORITHM:
1. Read the first input sequence, x[n] and plot.
2. Read the second input sequence, h[n] and plot
3. Find the length of x[n] and y[n] , l1 and l2 respectively
4. Check if l1=l2. Proceed only if equal.

5. If l1 not equal to l2, zero padding is done to make l1=l2.


6. Initialize a loop variable for the number of output points.
7. For each output sample access the samples of y[n] in cyclic order.

8. Find the sum of products of x[n] and cyclically folded and shifted h[n] to get circular
convoluted output.
9. Display and plot the output.

PROGRAM: CIRCULAR CONVOLUTION IN TIME DOMAIN


clc; % clear screen
clear all; % clear workspace
close all; % close all figure windows
xn= input('enter the first sequence x(n) = '); % define first sequence
hn=input('enter the second sequence h(n) = '); % Define second
sequence l1 = length(xn); % length of first
sequence
l2 = length(hn); % length of second sequence

10
N = max(l1,l2); % Define the length of the output
xn = [xn, zeros(1,N-l1)]; % zero padding is done to make l1=l2.
hn = [hn, zeros(1,N-l2)]; % zero padding is done to make l1=l2.
for n=0:N-1; % loop to calculate circular
convolution y(n+1) = 0;
for k=0:N-1
i = mod((n-k),N);
y(n+1) =y(n+1)+hn(k+1)*xn(i+1);
end ;
end;
disp('Circular convolution in Time Domain = ');
disp(y); % display the output
subplot(2,2,1); % graphical plot the first input
sequence stem(xn);
xlabel('n');
ylabel('x(n)');
title('Plot of x(n)');

subplot(2,2,2); % graphical plot the second input


sequence stem(hn);
xlabel('n');
ylabel('h(n)');
title('Plot of h(n)');
subplot(2,2,3); % graphical plot the output
sequence stem(y);
xlabel('n');
ylabel('y(n)');
title('Circular Convolution Output');

OUTPUT:

enter the first sequence x(n) = [1 1 2 1]


enter the second sequence h(n) = [1 2 3 4]

11
Circular convolution in Time Domain =
13 14 11 12
OUTCOME: Circular convolution of the sequences are found and the results are verified in
MATLAB

EXPERIMENT NO- 5 :- N-POINT DFT

AIM: To compute n-point DFT of a given sequence and to plot magnitude and phase
spectrum.

OBJECTIVE:
1. To find the N point DFT of a given sequence using the MATLAB inbuilt function

“FFT” and to find Magnitude and Phase of DFT sequence using functions “ABS and
ANGLE”
2. To verify the result theoretically.

.THEORY:Discrete Fourier Transform is a powerful computation tool which allows us to


evaluate the Fourier Transform X(e jw ) on a digital computer or specially
designed digital
hardware. Since X( e jw) is continuous and periodic, the DFT is obtained by sampling
one period of the Fourier Transform at a finite number of frequency points. Apart from
determining the frequency content of a signal, DFT is used to perform linear filtering
operations in the frequency domain.

The sequence of Ncomplex numbers x0,...,xN−1 is transformed into the sequence of N


complex numbers X0, ..., XN−1 by the DFT according to the formula:

, k = 0,1, …. N-1

For k = 1,
X(0) = x(0) + x(1) + x(2) +

-jπ/2 -jπ -j3π/2


X(1) = x(0) + x(1) e + x(2) e + x(3) e
X(1) = 1 + cos(π/2) - jsin(π/2)
X(1) = 1 – j
12
For k = 2

-jπ -j2π
-j3π
X(2) = x(0) + x(1) e + x(2) e + x(3)
e
X(2) = 1 + cos π – jsin π
For k = 3, X(2) = 1-1 = 0

13
-j3π/2 -j3π -j9π/2
= x(0) + x(1) e + x(2) e + x(3) e
X(3) = 1 + cos(3π/2) -
jsin(3π/2) X(3) = 1 + j
The DFT of the given
sequence is, X(k) = { 2, 1-j,
0, 1+j }
To find Magnitude of X(k):

Magnitude= (a +b )
Where a and b are real and imaginary parts
respectively To fine Phase of X (k):
-1
Phase=tan (b/a)

ALGORITHM:

1. Enter the number of points N


2. Enter the input sequence elements x[n]
3. Create a vector for sample index n
4. Calculate DFT using built in function FFT
5. Plot the magnitude and phase spectrum

PROGRAM: N POINT DFT


clc; % clear screen
close all; % close all figure windows
clear all; % clear work space
N = input('enter the N point = '); % define the number of points to be taken
for DFT xn = input('enter the input sequence x(n) = '); % input sequence
Xk = fft(xn,N); % find the N
point DFT disp('N point DFT of x(n) is = ' );
disp(Xk); % display the DFT of the input
sequence figure(1);
n = 0:1:length(xn)-1; % define x axis for input
stem(n,xn); % plot the input
xlabel('n');
ylabel('x(n)');
title('original
signal');
figure(2);
k = 0:N-1; % define the x axis for output
sequence
stem(k,abs(Xk)); % plot the absolute value
of output xlabel('k');
ylabel('|X(k)|');
title('Magnitude
spectrum'); figure(3);
stem(k,angle(Xk)); % stem(k. (angle(Xk)*180/pi)), plot the
phase of DFT xlabel('k');
ylabel('<X(k)')
; title('Phase
spectrum');

OUTPUT:
enter the N point = 4
enter the input sequence x(n) =
[0 1 2 3] N point DFT of x(n) is
=
6.0000 -2.0000 + 2.0000i -2.0000 -2.0000 - 2.0000i

PROGRAM: N POINT DFT USING FUNCTION


clc; % clear screen
close all; % close all figure windows
clear all; % clear work space
N = input('enter N point ='); % define the number of points to be taken
for DFT xn = input('enter the input sequence x(n) = '); % input sequence
Xk = dft(xn,N); % find the N point DFT
n = 0:1:N-1; % x axis values for plotting
input
k = 0:1:N-1; % x axis values for
plotting output disp('N point DFT of x(n) = ');
disp(Xk); % display DFT
subplot(2,2,1) % graphical plot of input
signal
stem(n,xn);
xlabel('n');
ylabel('x(n)');
title(' input signal');
subplot(2,2,2); % graphical plot of magnitude of
output signal stem(k,abs(Xk));

xlabel('n');
ylabel('|X(K)|');
title('Magnitude
spectrum');
subplot(2,2,3); % graphical plot of angle of
output signal stem(k,angle(Xk)*180/pi);
xlabel('n');
ylabel('<X(K)'
); title('Phase
spectrum');
%function file

function [Xk]
= dft(xn,N) n
= 0:1:N-1;
k = 0:1:N-1;
WN = exp(-
j*2*pi/N); nk
= n'*k;
WNnk =
WN.^nk;
Xk =
xn*WNnk;

OUTPUT:
enter N point = 4
enter the input sequence x(n) =
[1 4 2 7] N point DFT of x(n) =
14.0000 -1.0000 + 3.0000i -8.0000 - 0.0000i -1.0000 - 3.0000i
OUTCOME: DFT of the given sequence is found and the results are verified
using MATLAB.

VIVA QUESTIONS WITH ANSWER

1. DFT gives discrete spectrum or continuous spectrum? Justify?


DFT gives discrete spectrum. If the signal is periodic then spectrum is discrete
and if
the signal is non-periodic then spectrum is continuous. DFT assumes that input signal is
periodic and therefore DFT gives discrete spectrum.

2. How to find energy of signal from its DFT?


According to Parseval's energy theorem, Energy of the signal is given by.

3. What is the need of FFT?

It may be noted that the number of complex multiply and add operations required
by
the simple forms both the DFT and IDFT is of order N2. This is because there are N
data points to calculate, each of which requires N complex arithmetic operations. In

computer science jargon, we say they have algorithmic complexity O(N2). This is not
good news. If we can't do any better than this then the DFT will not be very useful
for the majority of practical DSP applications. Fortunately, there are a number of
different 'Fast Fourier Transform' (FFT) algorithms that enable us to do very much
better than this.

4. What is FFT? What is difference between DIT and DIF FFT?

A fast Fourier transform (FFT) is an efficient algorithmto compute the


discrete Fourier transform (DFT) and it’s inverse.The most significant difference
between simple DIF and DIT algorithms is that DIF starts with normal order input
and generates bit reversed order output. In contrast, DIT starts with bit reversed order
input and generates normal order output. So if both forward and inverse transforms
are required and bit reversed addressing isn't available, then the choice would seem
clear. Use DIF for the forward transform and DIT for the inverse transform. (For the
inverse transform you will need to conjugate the twiddle factors.) Unfortunately, the
issue isn't quite so simple. If your performing FFT's on pure real data it may be
simpler to use a modified DIT for the forward transform and a modified DIF for the
inverse transform

5. How efficient is the FFT?

The DFT takes N2 operations for N points. Since at any stage the computation
required to combine smaller DFTs into larger DFTs is proportional to N, and there
are
log2(N) stages (for radix 2), the total computation is proportional to N log2(N).
Therefore, the ratio between a DFT computation and an FFT computation for the
same N is proportional
to N / log2(N). In cases where N is small this ratio is not very significant, but when
N becomes large, this ratio gets very large. (Every time you double N, the numerator
doubles, but the denominator only increases by 1.

6. FFT is faster than DFT. Justify.

FFT produces fast results because calculations are reduced by decomposition


technique. In FFT, N point DFT is decomposed into two N/2 point DFT’s, N/2 point
DFT is decomposed into N/$ point DFT’s and so on.. Decomposition reduces
calculations. FFT algorithms are implemented using parallel processing techniques.
Because calculations are done in parallel, FFT produces fast computations.

7. What do you mean by


Decimation? Decimation
means Sampling
8. Which algorithm is more powerful: DIT-FFT or DIF-
FFT? Computationally, both the algorithms are
exactly same

9. Why Radix-2 algorithms are fast compared to radix-3 algorithms. ?

In FFT, N point DFT is decomposed into two N/2 pt DFT's, N/2 pt DFT is
decomposed into N/4 pt DFT's and so on... Decomposition reduces calculations this
process continues till further decomposition is not possible. In radix-2 last level of
decomposition is when the length of signal becomes 2 pt. For minimum calculations
there must be maximum levels of decompositions. In Radix-2 algorithms, we get
maximum levels of decompositions and therefore a radix-2 algorithm requires less
calculation. Radix-2 algorithms are fast algorithms.
EXPT NO: 6
TO FIND THE FFT OF A GIVEN SEQUENCE

AIM: To find the FFT of a given sequence


Software:
MATLAB
THEORY:
DFT of a sequence
N −1
X k x[n]e j 2 / N kn
n 0
Where N= Length of sequence.
K= Frequency Coefficient.
n = Samples in time domain.

FFT: -Fast Fourier transform.


There are two methods.
1. Decimation in time (DIT ) FFT.
2. Decimation in Frequency (DIF) FFT.
Why we need FFT?
The no of multiplications in DFT = N2.
The no of Additions in DFT = N (N-1).
For FFT.
The no of multiplication = N/2 log
2N. The no of additions = N log2 N.

Algorithm:

Step I : Give input sequence x[n].


Step II : Find the length of the input sequence using length command.
Step III : Find FFT and IFFT using matlab commands fft and ifft.
Step IV : Plot magnitude and phase response
Step V : Display the results
Flow Chart:

PROGRAM 1
MATLAB code for N-Point DIF FFT algorithm
clc;
clear all;
close all;
X=input('Enter the sequence : ');
N=input('Enter the Point : ');
n=length(X);
x=[X zeros(1,N-n)];
M=log2(N);
for m=1:M
d=2^(M-m+1);
for l=1:d:(N-d+1)
for k=0:(d/2)-1
w=exp(-1i*2*pi*k/d);
z1=x(l+k);
z2=x(l+k+d/2);
x(l+k)=z1+z2;
x(l+k+d/2)=(z1-z2)*w;
end
end
end

y=bitrevorder(x);
disp(y)
subplot(3,1,1)
stem(abs(X));
title('Input Sequence');
subplot(3,1,2)
stem(abs(y));
title('Magnitude Response');
subplot(3,1,3)
stem(angle(y));
title('Phase Response');

PROGRAM 2
MATLAB code for N-Point DIT FFT algorithm
clc;
clear all;
close all;
x=input('Enter the sequence : ');
N=input('Enter the Point : ');
n=length(x);
x=[x zeros(1,N-n)];
y=bitrevorder(x);
M=log2(N);
for m=1:M
d=2^m;
for l=1:d:N-d+1
for k=0:(d/2)-1
w=exp(-1i*2*pi*k/d);
z1=y(l+k);
z2=y(l+k+d/2);
y(l+k)=z1+w*z2;
y(l+k+d/2)=z1-w*z2;
end
end
end
disp(y);

subplot(3,1,1)
stem(abs(x));
title('Input Sequence');
subplot(3,1,2)
stem(abs(y));
title('Magnitude Response');
subplot(3,1,3)
stem(angle(y));
title('Phase Response');

Output:

Enter the sequence: [1 2 3 4 5]


x=1 2 3 4 5
N=5
xK = 15.0000, -2.5000 + 3.4410i, -2.5000 + 0.8123i , -2.5000 - 0.8123i, -2.5000 - 3.4410i
xn = 1 2 3 4 5

Output Waveform:
RESULT:
EXP.NO: 6
IMPLEMENTATION OF DECIMATION PROCESS

AIM: program to verify the decimation of given sequence.


SOFTWARE: MATLAB
THEORY:
“Decimation” is the process of reducing the sampling rate.
“Downsampling” is a more specific term which refers to just the process of throwing away
samples, without the lowpass filtering operation.
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.

Algorithm:

Step I : Define down sampling factor and input frequencies f1 and


f2 Step II : Represent input sequence with frequencies f1 and f2
Step III : Perform the decimation on input signal using matlab command
decimate. Step IV : Plot the input and output sequence

Flow Chart:

PROGRAM:
Clc;
Clear
all;
Close
all;
D=input('enter the downsampling factor');
L=input('enter the length of the input signal');
f1=input('enter the frequency of first sinusodal');
f2=input('enter the frequency of second
sinusodal'); n=0:L-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*
n); y=decimate(x,D,'fir');
subplot(2,1,1);
stem(n,x(1:L));
title('input
sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:(L/D)-1;
stem(m,y(1:L/D));
title('Decimated sequence');
xlabel('time(n)');
ylabel('amplitude');

INPUT:
enter the downsampling factor = 5
enter the length of the input signal = 100
enter the frequency of first sinusoidal = 0.01
enter the frequency of second sinusoidal = 0.03

Output Waveforms:

RESULT:
EXP. NO: IMPLEMENTATION OF
INTERPOLATION PROCESS

AIM: program to verify the decimation of given sequence.


SOFTWARE: MATLAB
THEORY
“Upsampling” is the process of inserting zero-valued samples between original samples to
increase the sampling rate. (This is called “zero-stuffing”.)
“Interpolation”, is the process of upsampling followed by filtering. The filtering removes
the undesired spectral images.
The primary reason to interpolate is simply to increase the sampling rate at the
output of one system so that another system operating at a higher sampling rate can input
the signal.

Algorithm:

Step I : Define up sampling factor and input frequencies f1 and


f2 Step II : Represent input sequence with frequencies f1 and f2
Step II : Perform the interpolation on input signal using matlab command
interp. Step IV : Plot the input and output signal/sequence.
Flow Chart:

PROGRAM:
Clc;
Clear
all;
Close
all;
L=input('enter the upsampling factor');
N=input('enter the length of the input signal'); % Length should be greater than
8 f1=input('enter the frequency of first sinusodal');
f2=input('enter the frequency of second
sinusodal'); n=0:N-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*
n); y=interp(x,L);
subplot(2,1,1)
stem(n,x(1:N))
title('input
sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:N*L-1;
stem(m,y(1:N*L))
title('output sequence
'); xlabel('time(n)');
ylabel('amplitude');
INPUT:
enter the upsampling factor = 5 enter
the length of the input signal = 9
enter the frequency of first sinusoidal = 0.1
enter the frequency of second sinusoidal = 0.3

Output Waveforms:

RESULT:

VIVA QUESTIONS:

1. Explain about multi rate digital signal processing.


2. List the Applications of multi rate digital signal processing.
3. Define interpolation.
4. Define decimation.
5. Define aliasing.

Exercise:

1. Perform interpolation on the input signal x(n)=cos(2*pi*30*n).

You might also like