Matlab: Different 1-D FFT results with and without zero-padded 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!
I don't know how MATLAB handles this internally. What will help in your situation however is multiplying your unpadded signal by a suitable window function, like a hann window. 

What you see in your diagrams is a convolution with a $\text{si}$ function, which is the fourier transform of a rectangle function. If you just take the signal as it is and transform it, you essentially multiply it by a rectangle function.

If you try this, for both of your cases, you should get matching results.