# Different amplitude for different time resolution with FFT [duplicate]

In the following Matlab code, the amplitude of the spectral domain signal is printed

Temporal_Pulse_Width=1;
t=linspace(0,20,2000);
dt=t(2)-t(1);
Time_Period=round(Temporal_Pulse_Width/dt);
AA=zeros(length(t),1);
AA(Time_Period/2:3*Time_Period/2)=1;
A=20*log10(abs(fftshift(fft(AA/length(t)))));
frequencyAxis = ((0:length(t)-1) -ceil((length(t)-1)/2))/length(t)/(t(2)-t(1));
plot(frequencyAxis,A,'LineWidth',3);
max(A)


If we change the vector t as follows,

t=linspace(0,10,2000);


The result (max(A)) will also change. How can I normalize the fft without having this problem?

• If you search for "fft scaling" on this side, you'll really find a lot of answers to your question. Just one: Mar 5 '21 at 8:16
• Does this answer your question? MATLAB: $\tt fft$ and $\tt ifft$ scaling Mar 5 '21 at 8:16

As you can see in MATLAB documentation for FFT

If you have Y = fft(x) then

$$Y_k = \sum_{j=1}^{N} x_j \cdot exp\left(-\frac{2 \pi i}{n} (k - 1) (j - 1)\right)$$

$$x_j = \frac{1}{n} \sum_{k=1}^{N} X_k \cdot exp\left(+\frac{2 \pi i}{n} (k - 1) (j - 1)\right)$$

Notice that the FFT is just a sum and the IFFT is divided by $$n$$, with this definition you know that  fft(ifft(x)) = x, but as the number of terms increase $$Y_k$$ will increase.

Your signal is a fixed duration pulse and you want a fixed amplitude in the frequency domain, so it is like an aperiodic Fourier transform

$$\int x(t) exp\left( \frac{2\pi i}{n} u t \right) dt$$

A zero order approximation for this can be obtained by computing

A=20*log10(abs(fftshift(fft(AA*dt))));


For the pulse of width 1, max(A) will be 0dB this way.

• Thanks a lot !! Mar 5 '21 at 9:42