Zero-Padding Position for FFT
Mostrar comentarios más antiguos
Hi,
I have a time-domain signal x with 5000 samples with period T, and it spans from -0.5*T to +0.5*T.
I want to compute an 8000-point FFT and I am confused about where I should add the zero-padding. Which of the following two methods is correct?
First:
x = [x; zeros(1, 3000)];
X = fftshift( fft( fftshift(x), 8000) );
Second:
x = [zeros(1, 1500); x; zeros(1, 1500)];
X = fftshift( fft( fftshift(x), 8000) );
Thanks!
Respuesta aceptada
Más respuestas (1)
If you only care about the amplitude spectrum the shifts don't really matter, but otherwise, you would do,
n=floor(numel(x)/2)+1; %location of the signal origin
x(end+1:8000)=0; %zero pad to 8000
xs=circshift(x, 1-n); %shift so that signal origin is at xs(1)
X = fftshift( fft( xs ) ); %transform
2 comentarios
Matt J
el 2 de Jul. de 2025
If you only care about the amplitude spectrum the shifts don't really matter
And in that case, it simplifies to,
x(end+1:8000)=0; %zero pad to 8000
X=fftshift( abs(fft(x)) );
Paul
el 2 de Jul. de 2025
Or just
X = fftshift(abs(fft(x,8000)))
so as to not corrupt the original data vector.
Categorías
Más información sobre Spectral Measurements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!










