EQ2300 Digital Signal Proessing Pro jet Assignment 1, Fall 2010 About the Pro jet The purpose of this projet is to provide some experiene with Matlab programming by implementing a blok based signal proessing method overed in the ourse. To this end, you shall implement either the overlap-save or overlap-add method. These are desribed in Setion 1.3.1 and Setion 1.3.2 of the omplementary reading material. You an hoose to implement either method, but you only have to implement one. You may also nd Setion 1.4 helpful when answering the questions of the projet. The projet assignment should be reported by lling in the form on the last page of this projet desription and inluding your Matlab ode. The answers may be written in Swedish or English. You an work on the projet individually or in a group of at most 2 students. However, disussing the projet and reeiving help from other students is allowed if you speify who helped you. The following is required for a passing grade: • A solution to the projet tasks, doumented by lling in the form at the last page. You should also attah a printed opy of your Matlab implementation. Staple the pages together. • One or two authors per report. • If you reeive help from others, identifying these other individuals. • When solving the problem, you should only use Matlab funtions that you understand well enough to be able to explain what they do. The reports will be graded with Pass or Fail. A passing grade is required for you to omplete the ourse. If the report does not pass, it should be revised and turned in before a new deadline. Note that if the report does not pass the seond time, a new projet has to be ompleted the following year. Reports that are turned in after the deadline will not be graded. • Deadline: Friday, November 12, 2010 to STEX Note that STEX is open 11.0014.00! 1 Filtering in Matlab The task is to lter a sequene x(n) of length K = 105 by a linear FIR lter with inpulse response h(n) of length M = 4000, i.e., x(n) = 0 for n < 0 and n ≥ K and h(n) = 0 for n < 0 and n ≥ M . Sine the partiular values of x(n) and h(n) are not important for the projet, we an hoose them randomly. You an reate two i.i.d. random Gaussian signals in Matlab by writing x = randn(1,K); h = randn(1,M); where K=1e5 and M=4000 are the lengths of the sequenes. You an ompute the output of the lter by onvolving x(n) and h(n) in Matlab by typing y = onv(x,h); However, the point of the projet is that you shall implement the same operation in the frequeny domain by using either the overal-save or overlap-add method. Tasks 1. Filter the signal x(n) by using the built in onv funtion and measure the time that it takes. 2. Compute the optimal value for the FFT blok-length N to be used by the overlap-save or overlap-add proedure for the senario desribed above. Here, optimal should be understood to mean the value of N that leads to the smallest number of omplex multipliations per sample. You may assume that N is an even power of 2, i.e., N = 2p . 3. Write a Matlab program that lters x(n) using either overlap-save or overlapadd. Attah the printed ode of this program to your answersheet. Measure the time that it takes for the program to omplete its task. 2 Pratial Details and tips • If you are ompletely unfamiliar with matlab, onsult www.mathworks.om and in partiular www.mathworks.om/moler/intro.pdf. • For a vetor h of length M , you an ompute the M-point DFT of this vetor by writing H = fft(h) in Matlab. The ommand fft(h,N) omputes the N-point DFT by adding zeros to h if N > M or trunating h if N < M . The inverse transform is omputed by h = ifft(H). • You an obtain the time required to omplete a task in Matab by using the ti and to ommands. For instane, ti; H = fft(h); to will display the time (in seonds) it takes to ompute the M point DFT of h(n) using the built in FFT funtion. • You an aess the elements in a Matleb vetor h between indexes a and b by writing h(a:b). Similarly, writing h(a:b) = f will set the same values to be equal to f. Note here that the length of f must be b-a+1. • Remember that the rst element of a Matlab vetor has index 1, not 0. • To verify that your solution works orretly, ompare its output to that provided by onv. If it works orretly, the outputs should be idential up to some numerial round-o errors. 3 4 EQ2300, Digital Signal Proessing, Projet 1 Author 1 Author 2 Name Personnummer Email How long did it take to lter x(n) using the built in funtion onv? ................................................................................ ................................................................................ What is the optimal value of the FFT length N used in overlap-save and overlapadd? How many omplex multipliations per sample does it take? ................................................................................ ................................................................................ Whih implementation (overlap-save or overlap-add) did you hoose and how long did it take to lter x(n) using your implementation? Is it faster than the built in funtion onv? If yes, what do you think the reason for this may be (feel free to speulate)? If no, why do you think that this is? ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ When preparing our solution, we were (or I was) helped by: . . . . . . . . . . . . . . . . . . . . . ................................................................................