function [ y ] = convolve2(x, h) % This function utilizes the convolution theorem and the FFT. % First the input vectors are padded with 0's to be the same length. Then % they undergo the FFT. the resultant vectors are multiplied and the final % result undergoes the inverse FFT. a = [x, zeros(1,length(h)-1)]; b = [h, zeros(1,length(x)-1)]; c = fft(a); d = fft(b); y = c.*d; y = ifft(y); end