I have followed the link below to simulate two different zero-padding methods (zero-centered and casual)
https://ccrma.stanford.edu/~jos/mdft/Zero_Padding.html
Sample code
close all;
clear all;
x = [3 2 1 1 2];
n = length(x);
fft_len = 64;
zeropadd = fft_len - n;
y = [x(1:(n-1)/2+1) zeros(1,zeropadd) x((n-1)/2+2:end)];
x_zeropad = [x zeros(1,zeropadd)];
y_fft = fft(y);
x_fft = fft(x, fft_len);
x_zp_fft = fft(x_zeropad);
subplot(311)
stem(y_fft)
xlabel 'n',
ylabel 'fft(y)'
subplot(312)
stem(x_fft)
xlabel 'n',
ylabel 'fft(x)'
subplot(313)
stem(x_zp_fft)
xlabel 'n',
ylabel 'fft(x_zp)'
Output is
My question is why is the spectrum of fft(y)
is different from fft(x)
and fft(x_zp)