% matlab/fftconvexample.m x = [1 2 3 4 5 6]; h = [1 1 1]; nx = length(x); nh = length(h); nfft = 2^nextpow2(nx+nh-1) xzp = [x, zeros(1,nfft-nx)]; hzp = [h, zeros(1,nfft-nh)]; X = fft(xzp); H = fft(hzp); Y = H .* X; y = real(ifft(Y))
Program output:
octave:10> fftconvexample nfft = 8 y = 1 3 6 9 12 15 11 6