rng = [ceil(newsz/2)-ceil(sz/2)+1;ceil(newsz/2)-ceil(sz/2)+sz]';
and replace it with
rng = [ceil(newsz/2)-floor(sz/2)+1;ceil(newsz/2)-floor(sz/2)+sz]';
then the code also works with odd dimesions.
Matthias, I cannot get this to work. The example image posted seems to interpolate the peaks dataset by a factor of two. But when I run the following code, I don't get the same result:
>>> figure; subplot(1,2,1); imagesc(peaks);
>>> subplot(1,2,2); imagesc(fftInterpolate(peaks,2));
what's going on?