I'm trying to transforming an already know signal from time domain to frequency domain using fft function in MATLAB. And I got different values of amplitude when I change the value of length of signal $L$. I'm therefore wondering if there is a rule to choose the length of signal when calculating FFT.

I have an acoustic signal got from a sensor and need to analyze it (I have no idea about its frequency range, amplitude, and so on.) I want to transform it into frequency domain using fft function in MATLAB. And I don't know how can I choose the length of signal.

Could somebody please help?


3 Answers 3



The length of the FFT depends on what application you are doing. A very course summary follows:

Same size FFT:

  • Analysis: This just means you want to 'analyse' the signal - look and see what type of spectrum it has, maybe patterns in the spectrums, etc. The 'usual' default is to simply use the FFT length equal to the length of your signal. Example: "What is the frequency content of my signal look like?"

    z = abs(fft(x));

  • Circular convolution: In circular convolution, you want to convolve two signals circularly, as opposed to 'normal' linear convolution. So if you have a signal $x$ of length $L$, and you want to circularly convolve with signal $y$ of length $L$ also, you can multiply their same length FFTs with each other, and then take the IFFT. Example: "What is the circular convolution of $x$ and $y$?"

    z = ifft(fft(x).*fft(y))

Different Length FFT:

  • Analysis: You can also use different (bigger) size FFTs for analysis as well. For example, if your signal $x$ was of length $L$, you can still analyze its frequency content choosing an FFT size of length, say, $10*L$. If you do this, you are actually interpolating the frequency spectrum. This just means that the spectrum looks more 'smooth', and in some cases you are able to better see where peaks might exist. Importantly though, this is not the same as increasing your frequency resolution. If someone tells you to "increase frequency resolution by taking a bigger size FFT", tell them they are wrong, and that this just interpolates the frequency domain. (Unless of course that person is your boss in which case you have to solve the non-linear optimization problem of telling them they are wrong without actually telling them they are wrong :-) ). (To actually increase frequency resolution, you need to have more samples of your original time domain signal). Anyway, the example motivation for this might be: "We analyzed our time domain signal using same size FFT, but we want to make sure the peaks we see are in the correct positions, let us increase the size of the FFT by 5 times".

    z = abs(fft(x,5*length(x)));

  • Linear convolution: In this case, you have to use a different size FFT. In linear convolution, a signal $x$ is convolved with a signal $y$. You might have heard that "Convolution in time is the same as multiplication in the frequency domain". This is true, but with the very important and often under-stated caveat that to do linear convolutions in the frequency domain, you have to make sure the FFT sizes are correct.

    The correct size of the FFT lengths for a linear convolution, is $N_{\text{fft}} = L_x + L_y - 1$, where obviously those lengths correspond to the length of your signals $x$ and $y$. Why is this the case? Because in linear convolution, the result of convolving two signals is always equal to the sum of their lengths, minus 1. Do it on paper and you will see. Convolve a signal of length 3, and another of length 2. The result will be of length 4.

    And so, as an example, one might say: "I want to linearly convolve two signals in the time domain, but I want to do this operation in the frequency-domain." They might do it like this:

    Lx = length(x);
    Ly = length(y);
    Nfft = Lx + Ly - 1;
    z = ifft ( fft(x,Nfft) .* fft(x,Nfft), Pfft);
    Hope this helps.

  • 4
    $\begingroup$ Have an up-vote from me for a great answer - it doesn't look good to have an accepted answer with a zero next to it. ;-) $\endgroup$
    – Paul R
    Commented Sep 7, 2012 at 16:13
  • $\begingroup$ the signal of mine is very long (?). It was sampled at the rate 5 MHz and it lasts about 5 seconds. Hence, the total samples in the time domain is about 5e6. Do I have to choose the length of signal as the whole signal? $\endgroup$
    – Mai
    Commented Sep 7, 2012 at 16:28
  • $\begingroup$ @Mai With modern computers, taking a 5 million point FFT should not be an issue. By the way there are only 2 lengths here, FFT length, and signal length. Don't confuse the two. If you want to 'see' very quickly what the spectrum of your audio signal looks like, (aka, analyse the spectrum), then look at my answer under 'analysis'. $\endgroup$
    – Spacey
    Commented Sep 7, 2012 at 16:36
  • 1
    $\begingroup$ @Mai Another thing to try since your signal is very long, is the Short Time Fourier Transform. I think there was a question/answer about it here on DSP stackexchange a while back. Basically that will break down your signal into segments which you can analyse individually. $\endgroup$
    – Spacey
    Commented Sep 7, 2012 at 16:37
  • 1
    $\begingroup$ @Mai Look at those answers here, and here $\endgroup$
    – Spacey
    Commented Sep 7, 2012 at 17:04

A longer FFT will divide up the frequency range into more "bins" between DC (0 Hz) and Fs/2. So the result bin of a particular frequency may be in a different bin number for different lengths of FFT. Depending on the FFT implementation, you may also need to divide by the length of the FFT or the square root of the length, or do plot interpolation (rescale) to get the FFT results of different lengths of a stationary signal to appear more similar.

The FFT length to choose depends on your signal (whether it is stationary or how fast it is changing).

If your signal is changing with time, then you will need to make a trade-off between locality in time, by choosing a shorter length so as not to mix together multiple time events in one FFT frame, or by choosing more frequency resolution (or frequency estimation accuracy), by using a longer length FFT.

If your signal is stationary (not changing over time), then you can increase the length to get the frequency resolution you require, or until the computational costs become too great.


You can choose whatever length you like. As long as it covers all the signals, they are the same spectrum with different "resolutions".


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.