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

DSP Lab Experiment-2

The document describes an experiment analyzing signals in the frequency domain using the discrete time Fourier transform (DTFT) and discrete Fourier transform (DFT) in MATLAB. It discusses: 1) Using the DTFT to find the frequency spectrum of an arbitrary sequence and prove the convolution property. 2) Using the DFT to find the frequency spectrum and inverse transform. Circular and linear convolution can be computed using the DFT convolution property. 3) MATLAB code examples to calculate the DTFT, DFT, and convolutions and observe the results.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

DSP Lab Experiment-2

The document describes an experiment analyzing signals in the frequency domain using the discrete time Fourier transform (DTFT) and discrete Fourier transform (DFT) in MATLAB. It discusses: 1) Using the DTFT to find the frequency spectrum of an arbitrary sequence and prove the convolution property. 2) Using the DFT to find the frequency spectrum and inverse transform. Circular and linear convolution can be computed using the DFT convolution property. 3) MATLAB code examples to calculate the DTFT, DFT, and convolutions and observe the results.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DIGITAL SIGNAL PROCESSING LABORATORY (EC-3096)

EXPERIMENT-2: Analyze the signal and its properties in the frequency domain using the
MATLAB programming. Use the Discrete time Fourier transform (DTFT) and Discrete Fourier
Transform (DFT) for discrete signal analysis in frequency domain, and perform circular convolution
using DFT.

 To find the DTFT of an arbitrary sequence and prove the convolution property using
programming.

THEORY: The discrete-time Fourier transform (DTFT) is the tool of choice for frequency domain
analysis of discrete-time signals and signal-processing systems.The discrete time Fourier transform
synthesis formula expresses a discrete time, aperiodic function as the infinite sum of continuous
frequency complex exponential.

X � = � � . �−���
�=−∞

The discrete time Fourier transform analysis formula takes the same discrete time domain signal and
represents the signal in the continuous frequency domain.
π
1
x n = X ω . ejωn

−π

The DTFT of any signal is periodic with a period of 2� . DTFT gives much higher number of
frequency contents as compared to DFT which may be considered as sampled version of DTFT itself.

Convolution property of DTFT: The convolution of discrete-time signals and � is defined as

This is sometimes called acyclic convolution to distinguish it from the cyclic convolution used for
length sequences in the context of the DFT.

The convolution theorem is then

Where � and � denote the DTFTs of � and � respectively. That is, convolution in the time domain
corresponds to point-wise multiplication in the frequency domain.
MATLAB CODES:
*DTFT function:
function [X,n,w]=dtft_x(x)
n=0:length(x)-1;
w=-pi:2*pi/500:pi;
W=exp(-j*n'*w);
X=x*W;

*Determination of DTFT of arbitrary sequence and proof of convolution property:


clc
clear all
close all
%x=input('enter the sequence: ');
n=0:20;
x=(0.5).^n;
[X,n,w]=dtft_x(x);
subplot(311), stem(n,x);xlabel('time: n');ylabel('amplitude: x');title('time domain plot of the signal');
subplot(312), plot(w,abs(X));xlabel('frequency: w');ylabel('amplitude: X');title('Magnitude spectrum');
subplot(313), plot(w,angle(X));xlabel('frequency: w');ylabel('amplitude: X');title('Phase spectrum');
%convolution
x1=input('enter the first sequence: ');
h=input('enter the second sequence: ');
y=conv(x1,h);
[X1,n,w]=dtft_x(x1);
[H,n,w]=dtft_x(h);
[Y,n,w]=dtft_x(y);
Y1=X1.*H;
figure
subplot(411), plot(w,abs(Y)); xlabel('frequency: w');ylabel('amplitude: X');title('Magnitude spectrum
of conv(x,h)');
subplot(412), plot(w,abs(Y1));xlabel('frequency: w');ylabel('amplitude: X');title('Magnitude spectrum
of X1.*H');
subplot(413), plot(w,angle(Y));xlabel('frequency: w');ylabel('amplitude: X');title('phase spectrum of
conv(x,h)');
subplot(414), plot(w,angle(Y1));xlabel('frequency: w');ylabel('amplitude: X');title('Phase spectrum of
X1.*H');
RESULTS:

Simulation results are shown below:


The above figure displays the magnitude and phase spectrum of the signal � � = 0.5 ��(�).
The below figure proves the convolution property of DTFT.
 To find DFT and IDFT and use it to find circular and linear convolution of given sequences.
THEORY:
The DFT is one of the most powerful tools in digital signal processing; it enables us to find the
spectrum of a finite-duration signal x(n). Basically, computing the DFT is equivalent to solving a set
of linear equations. The DFT provides a representation of the finite-duration sequence using a
periodic sequence, where one period of this periodic sequence is the same as the finite-duration
sequence. As a result, we can use the discrete-time Fourier series to derive the DFT equations. The
DFT of a sequence �(�) is written as:
�−1
2�
� � = � � �−� � ��
�=0

The inverse DFT of �(�) is determined using:


�−1
1 2�
�(�) = � � �� � ��

�=0

Equation 1 can be determined using twiddle factor matrix given by:


0.(N−1)
W0.0
N ⋯ WN
W= ⋮ ⋱ ⋮
(N−1).0 (N−1).(N−1)
WN ⋯ WN
2�
�� = �−� �
By using matrix multiplication X = W ∗ x

MATLAB CODES:
*Function for DFT & IDFT:
function[X, n]=dft_x(x, N,a) % if a=1, finds DFT and if a=2 finds IDFT, default is finding DFT
lx=length(x);
n=0:N-1;
Wn=exp(-j*2*pi/N);
W=Wn.^(n'*n);
x=[x zeros(1,N-lx)];
if a~=2
X=x*W;
else
X=x*conj(W)/N;
end

*Codes for determining DFT and IDFT, & circular and linear convolution using DFT:
clc;
clear all;
x=input('enter the sequece');
lx=length(x);
N=input('enter the length of DFT:');
[X,k]=dft_x(x,N,1)
[x1,n]=dft_x(X,N,2)
subplot(411), stem(0:length(x)-1,x);xlabel('time: n');ylabel('input x(n)');title('plot of input signal');
subplot(412), stem(k,abs(X));xlabel('frequency index: k');ylabel('magnitude of X(k)');title('magnitude
plot of DFT of x');
subplot(413), stem(k,angle(X));xlabel('frequency index: k');ylabel('phase of X(k)');title('phase plot of
DFT of x');
subplot(414), stem(n,x1);xlabel('time: n');ylabel('IDFT of X(k)');title('plot ofIDFT of X(k)');
%%%%circular convolution
%%x1Ox2---->X1*X2

x1=input('enter first sequence');


x2=input('eter second sequence');
lx1=length(x1);
lx2=length(x2);
%circular convolution
N=input('enter the length of circular convolution:');
n=0:N-1;
[X1,k]=dft_x(x1,N,1);
[X2,k]=dft_x(x2,N,1);
[x1x2_cconv,n]=dft_x(X1.*X2,N,2)
figure;
subplot(411), stem(0:length(x1)-1,x1); xlabel('time: n');ylabel('first input x1(n)');title('plot of first
input signal');
subplot(412), stem(0:length(x2)-1,x2); xlabel('time: n');ylabel('second input x2(n)');title('plot of
second input signal');
subplot(413), stem(n,x1x2_cconv); xlabel('time: n');ylabel('circular convolution of x1 &
x2');title('plot of circular convolution of x1 & x2 using DFT');
%linear convolution
N=lx1+lx2-1;
[X1,k]=dft_x(x1,N,1);
[X2,k]=dft_x(x2,N,1);
[x1x2_conv,n]=dft_x(X1.*X2,N,2)
subplot(414), stem(n,x1x2_conv); xlabel('time: n');ylabel('linear convolution of x1 & x2');title('plot
of linear convolution of x1 & x2 using DFT');

RESULTS:
The below figure displays an arbitrary signal �(�), its DFT � � and inverse DFT of � � . The IDFT
can be seen as same as � � .
The circular convolution of two signals can be found by using the convolution property of DFT which
says that the DFT of circular convolution of two signals is same is the point-wise multiplication of
individual DFTs of the two signals.
The linear convolution can be determined using circular convolution if the number of points in
circular convolution is kept as sum of the lengths of two sequences minus 1. The below figure
displays the results obtained using these fundamentals.
CONCLUSION:

You might also like