Lets say I want to double the number of points in an array f. I had the idea to do this:
F=fft(f);N=length(f);
FF=[F(1:N/2) zeros(1,N) F(N/2+1:N)];
f=ifft(FF);
But the result is not exactly correct. Why is this?
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.
Sign up to join this communityIf N
is odd it's a bit simpler:
FF=2*[F(1:(N+1)/2),zeros(1,N),F((N+3)/2:N)];
ff=real(ifft(FF));
This is very close to what you had (apart from the scaling). Also note that due to numerical inaccuracies you have to take the real part of the IFFT operation. However, you should always check that the imaginary part (which you throw away) is very small (in the order of $10^{-16}$ when using double).
If N
is even, you need to split the value at Nyquist:
FF=2*[F(1:(N/2)),.5*F(N/2+1),zeros(1,N-1),.5*F(N/2+1),F((N/2+2):N)];
ff=real(ifft(FF));
Doing DFT based interpolation has to keep 3 principles:
By the way, the interpolation isn't by a Sinc Kernel, it is done with its discrete form - The Dirichlet Kernel.