I have followed the link below to simulate two different zero-padding methods (zero-centered and causal)
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 = 32;
zeropadd = fft_len - n;
y = [x(1:(n-1)/2+1) zeros(1,zeropadd) x((n-1)/2+2:end)];
y_normal = [y(fft_len/2+2:fft_len) y(1:fft_len/2)];
x_zeropad = [x zeros(1,zeropadd)];
y_fft = fft(y);
y_normal_fft = fft(y_normal);
x_fft = fft(x, fft_len);
x_zp_fft = fft(x_zeropad);
subplot(421)
stem(y)
xlabel 'n',
ylabel 'y'
subplot(422)
stem(y_fft)
xlabel 'n',
ylabel 'fft(y)'
subplot(423)
stem(y_normal)
xlabel 'n',
ylabel 'y-normal'
subplot(424)
stem(y_normal_fft)
xlabel 'n',
ylabel 'fft(y-normal)'
subplot(425)
stem(x)
xlabel 'n',
ylabel 'x'
subplot(426)
stem(x_fft)
xlabel 'n',
ylabel 'fft(x, fft_len)'
subplot(427)
stem(x_zeropad)
xlabel 'n',
ylabel 'x-zp'
subplot(428)
stem(x_zp_fft)
xlabel 'n',
ylabel 'fft(x-zp)'
Output is
My question is why is the spectrum of fft(y)
, fft(y_normal)
is different from fft(x)
and fft(x_zp)