MATLAB Answers

Rick Rosson

Scaling the FFT and the IFFT

Asked by Rick Rosson
on 13 Sep 2011
Latest activity Commented on by Image Analyst
on 10 Nov 2015

What is the correct way to scale results when taking the Fast Fourier Transform (FFT) and/or the Inverse Fast Fourier Transform (IFFT)?



4 Answers

Answer by Rick Rosson
on 13 Sep 2011
 Accepted answer

Does scaling matter?

In most situations, scaling is really not all that important. The overall shape of the spectrum matters much more than the absolute scale.

What are the conventions?

But if you really are worried about it, there are several different conventions from which you can choose (see definitions below):

  1. Scale by dt for the FFT, and by Fs for the IFFT
  2. Scale by 1/M for the FFT, and by M for the IFFT
  3. Scale by 1 for the FFT, and by 1 for the IFFT
  4. Scale by 1/sqrt(M) for the FFT, and by sqrt(M) for the IFFT.
  5. and so on.

I generally use either option #1 or option #2 depending on my mood and whether it's raining outside.


Here I am assuming that I have a discrete-time signal x represented as an M x N matrix, where M is the number of samples and N is the number of channels.

   [M,N] = size(x);

Furthermore, I am assuming that the sampling rate is Fs and that I have defined the time increment as

   dt = 1/Fs;

and the frequency increment as:

   dF = Fs/M;

What do all these conventions have in common?

All of these conventions have one thing in common: The product of the two scaling factors is always 1. Please note that the ifft function in MATLAB includes a scaling factor of 1/M as part of the computation, so that the overall round-trip scaling is 1/M (as it should be).




on 15 Feb 2012

If my scaling is 'dt', for 1-Dimension, is it should by dt^2 for 2-D, please ?

Elige Grant
on 16 Feb 2012

Are you sure you are supposed to get 1. This reminds me of another post:

Incidentally, you should probably turn this into another question.

omar thamer
on 19 Dec 2013

answer worked in case the reconstruction has the same length with original signal. What if the reconstruction has more length in order to do some prediction, How would you scale the ifft ?

Answer by Elige Grant
on 28 Jan 2012

You are right about scaling being unimportant if only the shape of the spectrum is desired. However, if it is necessary that the amplitudes in the frequency spectrum be correct, then there is only one option for scaling - your option #1. In order for Parseval's theorem to hold, the energy in the time domain must equal the energy in the frequency domain. The example below demonstrates this:

> N = 8;
> dt = 0.1;
> df = 1/(dt*N)
df =
> a = randn(N,1)
a =
> b = fft(a)*dt
b =
      0.10746 +    0.30519i
    -0.080365 +   0.075374i
      0.34826 +    0.17802i
      0.34826 -    0.17802i
    -0.080365 -   0.075374i
      0.10746 -    0.30519i
> energy_a = sum(a.*conj(a) * dt)  % Not necessary to use conj here
energy_a =
> energy_b = sum(b.*conj(b) * df) % Necessary to use conj here
energy_b =


Jonathan Dandy on 7 Sep 2013

This answer works out, but confuses what is actually going on.

The frequncy domain data (b) is first multiplied by dt (b=fft(a)*dt). It is then squared (b.*conj(b)) and finally multiplied by df. The net effect is dt^2*df. Since df is defined as 1/(dt*N), this reduces to dt/N.

The time-domain data (a) only has the multiplier dt. So, in the end, the ratio of coefficients on the frequency domain and time-domain energy is 1/N. This also agrees with the formulation of Parseval's theorem in the discrete domain. ( )

The reason dt and df are not needed for Parseval's theorem in the discrete domain is because dt and df are associated with continuous integral.

I am still sorting out the scaling. It seems like option 4 from the original value satisfies Parseval's equation. However, option 2 seems to mainatin the relationship between amplitudes (looking at DC levels) and has been suggested in a Matlab technical note (1702). There is also some good discussion about 1702 in Matlab Central.

omar thamer
on 19 Dec 2013

answer worked in case the reconstruction has the same length with original signal. What if the reconstruction has more length in order to do some prediction, How would you scale the ifft ?

Rick Rosson
on 5 Nov 2015

In the continuous case, dt and df are infinitesimal quantities, which approach 0 in the limit that defines the Fourier integral. In the MATLAB code, dt and df are variables that take on values that are strictly non-zero (and positive). So the variable dt in the code is not in any way the same thing as the infinitesimal quantity dt in the continuous Fourier integral (and likewise for the variable df versus the infinitesimal df).

Moreover, the fft function is an implementation of the discrete Fourier transform (DFT), not the continuous time Fourier transform (CTFT).

Answer by masoud Aghaei
on 7 Jul 2015

MVDR in multipath environment with high resolution method hi,how to simulate in matlab doa by mvdr in multipath environment and better performance by high resoultion method(esprit-music-wsf-spatial smoothing....)?


Answer by Chani
on 16 Sep 2015
Edited by Chani
on 16 Sep 2015

Hi everyone,

I tried both options mentioned above, namely option #1 and option #2 with a simple sine curve. The results of both options confuse me and I am hoping you can help clear things up.

The code I am referring to is the following:

dt = 0.05;          %Time step
t = [0:dt:10];      %Time vector
s = sin(2*pi*t);    %Signal vector
N = length(s);      %Number of data points
f_s = 1/dt;         %Sampling frequency
df = f_s/N;         %Frequency increment
NFFT = N;                               %FFT length used as second argument of fft()
y_option1 = fft(s,NFFT);                %Compute FFT using sampling interval as scaling factor
y_option1 = y_option1*dt;   
y_shiftOption1 = fftshift(y_option1);
y_option2 = fft(s);                     %Compute FFT using signal length as scaling factor
y_option2 = y_option2/N;
y_shiftOption2 = fftshift(y_option2); 
if mod(N,2) == 0 %N is even
    f = -f_s/2 : df : f_s/2-df;
else            %N is odd
    f = [sort(-1*(df:df:f_s/2)) (0:df:f_s/2)];

Plotting the sine signal and both result vectors y_shiftOption1 and y_shiftOption2 leads to the following Figure:

From my point of view the result of option #2 exhibits the correct amplitude of 0.5V, since the time signal has an amplitude of 1V and this value is split into the two impulses on the negative and the positive frequency scale.

However, regarding Parseval's Theorem, the energy is only preserved using option #1:

sum(abs(s).^2)*dt = 5
sum(abs(y_shiftOption1).^2).*df = 5
sum(abs(y_shiftOption2).^2).*df = 0.0495

Does this mean, if I am interested in the real amplitude of the signal, I have to use option #2 and if I want to preserve the energy of the signal option #1 has to applied?

Thanks in advance for your help!

Best Regards Chani


Rick Rosson
on 16 Sep 2015

Both graphs are correct, but each graph tells you something different. Remember, neither one of these graphs is showing you the spectrum itself, but rather each is showing you a discrete sampling of the spectral density versus frequency. The only difference between the two graphs is a simple scale factor, which represents nothing more than a difference in the units of measure for each graph.

Assuming that the unit of measure for the time domain signal is volts, then the units of measure are as follows:

  • For Option #1, the graph represents the spectral density in units of volts per hertz.
  • For Option #2, the graph represents the same spectral density, but now in units of volts.

The scale factor is nothing more than the value of df (in hertz), the frequency increment between each adjacent pair of discrete frequency values.

on 17 Sep 2015

Thanks for your explanation!

Image Analyst
on 10 Nov 2015

Shaui's flag on Rick's comment moved here to be a comment:


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!