Recently I am implementing FFT with C code. So I use Matlab for algorithm verification. As Radix-2 FFT was chosen, I've learned that zero-padding technique could help to reach 2^N limitation without messing up the result. However, hesitation has shown.
Let's say a set of acceleration data with the size of 150 (x) comes across. If FFT function is called directly like:
X = fft(x);
abs_X = abs(X);
figure
plot(abs_X(2:75)); % discard first data (DC)
The result looks reasonable:
With this result I can easily indicate the highest amplitude and get the main frequency with frequency step. However, after zero-padding the data to the size of 256 and then apply fft
, a confusing result is obtained.
x = [x; zeros(106,1)]; % pad 0 to 256
X = fft(x);
abs_X = abs(X);
figure
plot(abs_X(2:128)); % discard first data (DC)
Now I cannot identify the main frequency since the decreasing pattern is shown.
From here I have learned that the fft
function in Matlab will automatically adjust the data size with zero-padding in order to perform FFT. So theoretically two operations demonstrated above should perform same results. I know that zero-padding will increase the visual resolution (not data resolution). But the difference between the beginning of the figures, where main frequency can't be determined, is confusing me.
Can anyone help to clarify the situation? Or do I misunderstand something important about the statement "Zero padding is going to perform a same result."? Any comment is appreciated. Thank you for browsing my question!
fft
function? $\endgroup$