Zero-Padding Position for FFT
Show older comments
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!
Accepted Answer
More Answers (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 Comments
Matt J
on 2 Jul 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
on 2 Jul 2025
Or just
X = fftshift(abs(fft(x,8000)))
so as to not corrupt the original data vector.
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!









