Reputation: 243
I'm trying to compare Matlab fft of a cosinus with two different zero padding. I thought that it wouldn't change the frequency response but when I superimpose the two curves, the frequencies are not the same. I suppose that there is something wrong with the way I do my two fft?
Fe = 8000;
F = 1680;
w = 2*pi*F;
N = 50;
P = 50;
T = 1/Fe;
t = (0:T:P*T);
x = real(exp(i*w*t))
x_reduced = x(1:P)
X = fft(x_reduced,N)
N = 1000;
Y = fft(x_reduced,N)
plot(abs(Y))
hold on
plot(abs(X),'*')
Thanks in advance
Upvotes: 1
Views: 399
Reputation: 12689
plot((0:999)/1000*Fe,abs(Y))
hold on
plot((0:49)/50*Fe,abs(X),'*')
You may need to align the frequencies of both cases.
Upvotes: 6
Reputation: 212929
When you pad the FFT you change the resolution of each bin (you are effectively interpolating between bins), so while the corresponding frequencies are still the same of course the actual mapping to bin indices will change. If you were to scale the two FFT plots so that the horizontal axes for both line up (i.e. bin 0 aligned on both, and bin 50 aligned with bin 1000) then the plots would match.
Upvotes: 4