(MATLAB) In some cases, to calculate the convolution of two sequences, the convolution theorem of Discrete Fourier Transformation may be preferable instead of the direct application of the convolution summation. This is due to the smaller number of arithmetic operations (i.e. additions and multiplications) of the DFT-based method compared to the number of arithmetic operations of the convolution summation. The small number of arithmetic operations of the DFT is achieved by using an efficient implementation of the DFT, namely the FFT algorithm, which will be discussed at the end of the term.
i) Generate an N-point sequence, x[n], and an N-point filter, h[n], by using the round(randn(1,N)) command in MATLAB. Select N = 8192 first and then you may try larger values such as N = 2^15, etc. Select N = 100.
ii) Obtain the convolution result, ys[n] = conv(xs,h).
iii) Repeat ii) by using the convolution theorem of DFT (note you can calculate DFT using fft(x,L) where L is the DFT length you desire) to obtain y[n] as the result of the convolution of these two sequences. (Note that you need to select an appropriate length for the DFT to obtain linear convolution instead of circular convolution).
iv) Verify that ys[n] = yz[n].
v) What is the DFT length you used in iii)? In some applications, such large DFT sizes may not be allowed to wait to store such long sequences before processing. Hence, overlap-add or overlap-save methods can be used instead. Implement the overlap-add method where you are allowed to use DFT and IDFT of only length 256. What is the segment size range you can use? Let the result with the overlap-add method be ys[n] and verify it equals y[n] or yz[n].