"Samuele " <
samue...@hotmail.com> wrote in message <ju0emk$3j0$
1...@newscl01ah.mathworks.com>...
> Hello Everybody,
> I have a question corning the zero padding and the FFT. I learned a couple of years ago that if I zeropad a vector in frequency domain and I come back in time domain, the vector in time domain is interpolated (i.e between the original samples I added samples that are "average" between two samples).
You should pad in the high frequencies, which are located in the middle of the output of the fft, not the tail of it.
% Example data
n = 100;
x=linspace(-3,3,n);
y=1./((x-0.5).^2+1);
z = fft(y);
% Pad the high frequency
padsize = 28/2;
if mod(length(z),2) % odd
zp = ifftshift([zeros(1,padsize) fftshift(z) zeros(1,padsize)]);
else % even
zp = fftshift(z);
zp(1) = zp(1)/2;
zp(end+1) = zp(1);
zp = ifftshift([zeros(1,padsize) zp zeros(1,padsize-1)]);
end
% Resampling, renormalization
xp = linspace(x(1),x(end),length(zp));
yp = ifft(zp)/length(z)*length(zp);
% Check
figure()
plot(xp,yp,'b',x, y,'r')
% Bruno