Top Banner
SIGNALS AND SYSTEMS-EEL 205 DFT AND ITS APPLICATIONS A study submitted at IIT,Delhi as a part of EEL 205 course requirement RISHABH DUDEJA (2011EE10477) AGAM GOEL (2011EE20505)
21

Dft and its applications

Dec 05, 2014

Download

Documents

Agam Goel

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Dft and its applications

SIGNALS AND SYSTEMS-EEL 205

DFT AND ITS APPLICATIONS

A study submitted at IIT,Delhi as a part of EEL 205 course requirement

RISHABH DUDEJA (2011EE10477)

AGAM GOEL (2011EE20505)

Page 2: Dft and its applications

ACKNOWLDGEMENT

We have taken great efforts in this project.

However, it would not have been possible without the

kind support and help of many individuals. I would like

to extend my sincere thanks to all of them.

We are highly indebted to Professor S.D Joshi for his

guidance and constant supervision. He provided us with

necessary information regarding the project &

invaluable support in completion of the project.

We would like to express our gratitude towards our

parents for their kind co-operation and encouragement

which helped us in the completion of this project.

My thanks and appreciations also go to my friends in

developing the project and people who have willingly

helped me out with their abilities.

Rishabh Dudeja

Agam Goel

Page 3: Dft and its applications

ABSTRACT

The study looks at an alternative representation of signals known as the

Discrete Fourier Transform (DFT). DFT has widespread applications in Spectral

Analysis of systems, LTI systems, Calculating convolution of signals,

multiplication of large polynomials, noise removal etc.

Computing DFT of a signal via normal computations takes a considerable time.

We have calculated DFT using the famous algorithm of Fast Fourier Transform

(FFT). There are several other variations to calculate DFT also.

Thereafter, we have looked at logics to compute Inverse DFT to get back a

signal from its DFT. This has been done using two well-known tricks which

involve conjugation and reversing of the DFT. We have implemented Linear

and Circular convolution using the normal methods and the DFT method.

We have plotted graphs for each algorithm to show their time complexity, by

using signals of various sample lengths. Also, to further validate our algorithms

, we have computed DFT’s and Inverse DFT using Matlab inbuilt function and

shown the results to be the same.

We have also shown the relationship between DFT and DTFT and that instead

of storing the whole continuous DTFT, we can simply store finite points of DTFT

and still recover the signal.

Along with the Project report, we have attached soft copies of the various

programs we have developed in Matlab along with their GUI implementation.

GUI implementation allows one to compute DFT’s Inverse DFT’s and

convolution for various types of signals from square to exponential and even

custom signals. Custom signals have to be input in the form of a list.

Page 4: Dft and its applications
Page 5: Dft and its applications

DISCRETE FOURIER TRANSFORM

The discrete Fourier transform (DFT) is a specific kind of discrete transform, used in Fourier analysis.

It transforms one function into another, which is called the frequency domain representation, or simply

the DFT, of the original function (which is often a function in the time domain. The DFT requires an

input function that is discrete. Such inputs are often created by sampling a continuous function, such

as a person's voice. The discrete input function must also have a limited (finite) duration, such as one

period of a periodic sequence or a windowed segment of a longer sequence.

Unlike the discrete-time Fourier transform (DTFT), the DFT only evaluates enough frequency

components to reconstruct the finite segment that was analyzed. The inverse DFT cannot reproduce

the entire time domain, unless the input happens to be periodic. Therefore it is often said that the DFT

is a transform for Fourier analysis of finite-domain discrete-time functions.

In particular, the DFT is widely employed in signal processing and related fields to analyze the

frequencies contained in a sampled signal, to solve partial differential equations, and to perform other

operations such as convolutions or multiplying large integers. A key enabling factor for these

applications is the fact that the DFT can be computed efficiently in practice using a fast Fourier

transform (FFT) algorithm.

FFT algorithms are so commonly employed to compute DFTs that the term "FFT" is often used to

mean "DFT" in colloquial settings. Formally, there is a clear distinction: "DFT" refers to a mathematical

transformation or function, regardless of how it is computed, whereas "FFT" refers to a specific family

of algorithms for computing DFTs.

The sequence of N complex numbers x0.... xN−1 is transformed into another sequence of N complex

numbers according to the DFT formula:

Page 6: Dft and its applications

FAST FOURIER TRANSFORM

One of the reasons for the significant increase in the use of computerised techniques was the

development of a very efficient technique known as the FAST FOURIER TRANSFORM (FFT) algorithm

for the calculation of the DFT of finite duration sequences.

One method of calculation of the DFT is by direct evaluation. A useful measure of the complexity of

such a computation is the total number of complex computations required. Clearly for calculation

each point of the DFT we require N computations and hence for a complete N point DFT we have N2

It is convenient to write the above equations as:

Where ,

Suppose that N is even and a power of 2. Let f[n]=X[2n] represent the even indexed samples and

g[n]=X[2n+1] represent the odd indexed samples.. Clearly f[n] and g[n] are zero outside the interval

0≤n≤(N/2)-1.

The N-point DFT of X[n] can be expressed as

Where

Also, clearly a N point DFT is periodic with period N. This main point is basically going to help us

decrease our computations. The N-point DFT of X[n] can be calculated in terms of two DFT’s of

length N/2. Even if we now compute the DFTs of the 2 halves using the traditional algorithm,

number of computations required is N2/2, less than N2. Actually these halves are further

decomposed and hence the computational advantage is enormous.

Page 7: Dft and its applications

If N is a power of two, then we can decompose function at every step into sequences of even and

odd indexed samples, and therefore their DFT’s can be computed using the same process. We can

iterate the process, thus achieving significant savings in computation time. The time complexity of

the program will be Nlog(N) which is a significant improvement over N2

To implement FFT using the matlab , firstly we have created a function ‘expmatrix’ which returns an

array of complex exponentials of desired period.

The following is the ‘myfft’ function which calculates the nearest power of 2 point DFT of the input

signal using the FFT algorithm as was described above. Note that even if we input a signal which is

not of length which is a power of 2, it converts it into one by zero-padding. That is the remaining

points are assigned the value of 0.

Here , we have taken samples of the sine signal, and then found out its DFT using the built in FFT and

our version of FFT. Finally, the signal has also been recovered using IFFT.

Page 8: Dft and its applications
Page 9: Dft and its applications

INVERSE FAST FOURIER TRANSFORM

One major advantage of the DFT is that that its inverse can be computed using the DFT function

itself.

Expressing the inverse DFT in terms of DFT (i.e. finding out the signal if its DFT has been given) can

be done using several well known tricks:

1) First, we can compute the inverse DFT by reversing the inputs:

The subscripts are interpreted modulo N.

Following is the program ‘myIFFTver2’ to calculate the inverse DFT using the above algorithm. Note

fliplr reverses the signal.

2) Second, one can also conjugate the inputs and outputs:

Following is the program ‘myIFFT’ to calculate the inverse DFT using the above logic.

Page 10: Dft and its applications

CIRCULAR CONVOLUTION USING DFT

Circular Convolution The circular convolution, also known as cyclic convolution, of two aperiodic functions occurs when one of them is convolved in the normal way with a periodic summation of the other function. That situation arises in the context of the Circular convolution theorem. The identical operation can also be expressed in terms of the periodic summations of both functions, if the infinite integration interval is reduced to just one period. That situation arises in the context of the discrete-time Fourier transform (DTFT) and is also called periodic convolution. In particular, the transform (DTFT) of the product of two discrete sequences is the periodic convolution of the transforms of the individual sequences. Circular convolution using DFT can be calculated in many ways. Algorithm 1 In this, Let X1[n] and X2[n] be the two signals whose circular convolution we have to compute. We calculate the N point DFT of both the signals. It is important to calculate the same point DFT of both the signals. The number of points in the DFT is the period of the circular convolution obtained. Now multiply the DFT’s point wise. After this calculate IDFT of the resultant to get the required solution. Consider the number of computations if we do the DFTs using FFTs: Each transform requires O (NLog(N))operations, the multiplication is O(N) , and the inverse transform is O(NLog(N)) . The overall computation is O (NLog(N)), which saves a significant amount of time , specially for large N.

Here is the matlab implementation of the above algorithm using the self designed DFT myfft.

Page 11: Dft and its applications

The code given below uses the inbuilt fft function.

Page 12: Dft and its applications

Algorithm 2 Circular convolution computed directly from its summation formula.

The above algorithm has been implemented in the function mycconv.

The function basically computes the value of circular convolution of the 2 functions from 0 to N-1 by actually evaluating the summation in an internal while loop. The first signal is treated as a finite hold signal and hence the upper and lower limits of the summation are N-1 and 0 rather than infinity and negative infinity. The second signal is assumed to be periodic with period N. Hence its arguments are taken modulo N. The order of the function coded above is O (N2). The computation of the convolved function at any point required computation of N products – x(0)y(n-0), x(1)y(n-1)…..x(n-1)y(1) and their summation i.e. O(N) operations. Since value of the convolved function needs to be computed at N pts, the overall order is O (N*N) =O (N2).

Page 13: Dft and its applications

Here, we have done circular convolution of sine and cosine. Period of convolution=150 Time for FFT based convolution=extremely small O( NlogN) Time for inefficient convolution (the one done in terms of linear convolution) =0.001594sec O(N2) Clearly, one can observe the huge time difference.

Page 14: Dft and its applications

LINEAR CONVOLUTION USING DFT

Algorithm 1 The linear convolution equals the circular convolution provided the period of the circular

convolution is large enough.

To see this interpret the circular convolution as:

The periodic extension of x2 is obtained by passing the discrete delta function through an LTI whose

impulse response is x2. Since the circular convolution is nothing but the linear convolution of x1 with

periodic extension of x2. It can be obtained as the response of an LTI with impulse response x1 to

periodic x2. The response thus obtained is multiplied by a rectangular window of size N to extract a

single period and hence find circular convolution. Since convolution is a commutative operation the

order of these LTIs can be changed as:

Page 15: Dft and its applications

Now, circular convolution can be simply interpreted as a periodic extension of linear convolution.

Now when 2 signals of M and L are convolved the linear convolution always has length M+L-1. If the

period for extension of this linear convolution is more than or equal to M+L-1, then the various

periods don’t interfere with each other and the linear convolution can be obtained as a one period

extraction of circular convolution. If it is less than L+M-1 aliasing occurs between various periods and

the linear convolution is lost.

Hence to obtain linear convolution we find the circular convolution of the 2 signals with a period

N>=L+M-1 say in particular L+M using the FFT based algorithm for circular convolution. We then

extract the first L+M-1 samples from the circular convolution and obtain the linear convolution in

the order of the DFT algorithm that is NlogN.

We have implemented it using both myfft functions:

Page 16: Dft and its applications

And built in FFT function:

Algorithm 2 Linear convolution computed directly from its summation formula.

If we have 2 signals f and g of finite holds say L and M, all indices in the summation aren’t valid in

fact the summation start index can be replaced by:

Start=max (0, n-M+1)

End=min (L-1, n)

Where n denotes the value at which f*g is being evaluated.

The program given below basically evaluates the summation explicitly using while loops. Like the

circular convolution it takes O (N2) time.

Page 17: Dft and its applications
Page 18: Dft and its applications

Here, we have done linear convolution between the exponential signal and the square signal.

Time for FFT based convolution=0.0001153sec

Time for inefficient convolution=0.0003166sec

Page 19: Dft and its applications

RELATIONSHIP BETWEEN DFT AND DTFT

A finite duration discrete signal which is non zero only between 0 to N-1 can be represented in

frequency domain using two transforms:

The Discrete time Fourier transform which defines a corresponding function X (Ω):

Since the signal is non zero beyond 0 and N-1,

And

Using the N-point DFT (N>signal length):

The 2 equations simply show:

What these means is that is nothing but the discretized version of , the number of

equispaced samples being equal to N. Note that the samples are only taken between

However, since is periodic with , these are sufficient.

Since, it is possible to reconstruct the the signal using both its DFT and its DTFT it simply shows that

the information contained in a continuous time signal can be stored by simply taking N

samples provided N is greater than the signal length.

This also suggests a method to approximate the DTFT plot in matlab by simply interpolating the N

samples of the N point DFT. The greater are the number of samples i.e. greater the value of N, the

more closely spaced samples are, and more continuous looking the DTFT plot is.

Page 20: Dft and its applications

The following figure shows the implementation:

The first plot is the signal, the second the closest power of 2 DFT and the last the DTFT plot by taking

at 1024 pt DFT.

Page 21: Dft and its applications

REFERENCES

LITERARY RESOURCES

Signals and Systems, 2nd edition, Alan V. Oppenheim

The scientist and Engineer’s guide to digital signal processing, Steven Smith

ONLINE RESOURCES

http://ocw.mit.edu/index.htm : Lectures By Alan Oppenheim on convolution

www.mathsworks.in

www.wikipedia.com

www.google.com

http://ee.sjtu.edu.cn

http://ee.sjtu.edu.cn/st/studio/my/9304/Fundamentals%20of%20Signal%20Processing/A.%

20Basics%20of%20Discrete%20Fourier%20Transform.pdf

http://www.physics.iitm.ac.in/~kavita/sujoyketan.pdf

http://www.ele.uri.edu/~hansenj/projects/ele436/fft.pdf