Sei sulla pagina 1di 7

Experiment No 2

July 2015

Date: 31st

Discrete Fourier Transform (DFT) and Inverse Discrete Fourier Transform (IDFT)

Aim: 1. To find the DFT of the sequence x[n] = [1 2 3 4] and verify by finding the
IDFT using the formula
method.
2. to find DFT of audio signal.
Theory:
In mathematics, the discrete Fourier transform (DFT) converts a finite list of equally
spaced samples of a function into the list of coefficients of a finite combination
of complex sinusoids, ordered by their frequencies, that has those same sample
values. It can be said to convert the sampled function from its original domain
(often time or position along a line) to the frequency domain. The DFT is the most
important discrete transform, used to perform Fourier analysis in many practical
applications. In digital signal processing, the function is any quantity or signal that
varies over time, such as the pressure of a sound wave, a radio signal, or
daily temperature readings, sampled over a finite time interval.
In image processing, the samples can be the values of pixels along a row or
column of a raster image. The DFT is also used to efficiently solve partial
differential equations, and to perform other operations such as convolutions or
multiplying large integers. The Discrete Fourier Transform can be calculated using
the following methods:
1. Formula Method:
The DFT can be calculated using the formula given below:
N 1

X ( k ) = x ( n ) e j 2 kn / N k=0,1,2, , N1
n=0

Also the IDFT can be evaluated using the formula,

x ( n )=

1
N

N 1

X (k ) e j 2 kn / N n=0,1,2,3, , N1
k=0

Theoretical Calculations:
Given x[n] = [1 2 3 4]

N=4,
N 1

X ( k ) = x ( n ) e j 2 kn / N
n=0

k =0
3

X ( 0 )= x ( n ) e 0
0

= x (0) + x (1) + x (2) + x (3)


= 1 + 2 + 3 + 4 = 10
k=1
3

X ( 1 )= x (n)e

n
4

= x (0 )e + x (1) e

+ x ( 2 ) e + x( 3)e

3
4

= -2+j2

Similarly for k=2, 3


X (2) = -2 and X (3) = -2-2j
To find the IDFT;

1
x ( n )=
N

N 1

X (k )e j 2 kn / N
k=0

x ( n )=

1
X (k) e jkn /4
4 0

Let n=0

X ( 0) + X ( 1) + X ( 2) + X (3)
1
x ( 0 )=
8
= 8/8 = 1

j
j
j
1
0
x ( 1 )= ( X ( 0 ) e + X ( 1 ) e 4 + X ( 2 ) e 2 + X ( 3 ) e 4 )
8

=2

Similarly x (2) = 3 and x (3) = 4

MATLAB Program:
1.To find DFT and IDFT:
clear all;
close all;
clc;
%Given Sequence
x=[1 2 3 4];
N=4;
sum=0;
%Calculation of DFT
for K=0:1:N-1
for n=0:1:N-1
sum=sum+(x(n+1)*exp((-1j*2*pi*K*n)/N));
end
X(K+1)=sum;
sum=0;
end
%Plotting figures
K=1:1:N;
%Plot Original Signal
subplot(2,2,1)
stem(K,x);
xlabel('n');
ylabel('x[n]');
title('Original Signal');
%Plots the real part of the DFT
p=real (X(K));
subplot(2,2,2);
stem(K,p);
xlabel('n');
ylabel('Real X[k]');
title('Real Part of DFT');
%Plots the imaginary part of the DFT
z=imag(X(K));
subplot(2,2,3)
stem(K,z);
xlabel('n');

ylabel('Img X[k]');
title('Imaginary part of DFT');
%Calculation of IDFT
for n=0:1:N-1
for K=0:1:N-1
sum=sum+((X(K+1)*exp((1j*2*pi*K*n)/N))/N);
end
z(n+1)=sum;
sum=0;
end
%Plots the IDFT Signal
n=1:1:N;
subplot(2,2,4)
stem(n,z(n));
xlabel('n');
ylabel('x[n]');
title('IDFT Signal');

2.Audio Signal:
clear all;
close all;
clc;
%Loads the audio file
x=load('chirp.mat');
x1=x.y;
n=1:1024;
%plots the audio signal
subplot(2,2,1)
stem(n,x1(n));
xlabel('n');
ylabel('x[n]');
title('Audio signal');
N=1024;
sum=0;
%Computes the DFT
for K=0:1:N-1
for n=0:1:N-1
sum=sum+(x1(n+1)*exp((-1j*2*pi*K*n)/N));
end
X(K+1)=sum;
sum=0;
end
%Plots the DFT
K=1:1:N;
subplot(2,2,2)
stem(K,real (X(K)));
xlabel('n');
ylabel('Real X[k]');
title('Real part of DFT');
subplot(2,2,3)
stem(K,imag (X(K)));
xlabel('n');
ylabel('Img X[k]');
title('Imaginary part of X[k]');
%Computes the IDFT
for n=0:1:N-1
for K=0:1:N-1
sum=sum+((X(K+1)*exp((1j*2*pi*K*n)/N))/N);
end
z(n+1)=sum;

end

sum=0;

%Plots the IDFT


n=1:1:N;
subplot(2,2,4)
stem(n,z(n));
xlabel('n');
ylabel('x[k]');
title('IDFT Signal');

Conclusion:

The DFT and IDFT was found successfully and implemented using MATLAB
programs and verified using theoretical calculations.

Potrebbero piacerti anche