function fg = convfast(f,g) % fg = convFast(f,g) performs convolution of f and g using the FFT % We use fft to padd with zeros N1 = length(f); N2 = length(g); L = pow2(nextpow2(N1+N2-1)); F = fft(f,L); G = fft(g,L); fg = ifft(F.*G); fg = fg(1:(N1+N2-1));