Clarification regarding FFT required

4 Ansichten (letzte 30 Tage)
Dor Assido
Dor Assido am 15 Dez. 2018
Kommentiert: David Goodmanson am 19 Dez. 2018
Hi everybody,
I'm trying to compute the Fourier Transform of a rectangular pulse using MATLAB 2013a and the FFT function.
I read the documentation which suggested that in order to normalise the results, a division by the signal length is required (link). However, I came across several sources claiming that in fact, a division by the sampling frequency is required. I decided to test both claims by running the following code:
T = 1e-9;
fs = 1e12;
Ts = 1/fs;
w = 2e-9;
t = -w:Ts:w;
Ft = rectpuls(t, T);
nFFT = 2^nextpow2(length(t));
FFT_Length = fftshift(fft(Ft, nFFT)/nFFT);
FFT_Sampling = fftshift(fft(Ft, nFFT)/fs);
f = (-nFFT/2:nFFT/2-1)*(fs/nFFT);
figure;
subplot(3,1,1);
plot(t/1e-9, Ft);
ylabel('F(t)')
xlabel('t [nsec]')
ylim([-0.5 1.5])
title('Rectangular Pulse')
subplot(3,1,2)
plot(f/1e9,(FFT_Length))
xlabel('f [GHz]')
ylabel('$$\tilde{F}(f)$$','Interpreter','Latex')
xlim([-5 5])
title('FFT Normalised by Signal Length')
subplot(3,1,3)
plot(f/1e9,(FFT_Sampling))
xlabel('f [GHz]')
ylabel('$$\tilde{F}(f)$$','Interpreter','Latex')
xlim([-5 5])
title('FFT Normalised by Sampling Frequency')
The plot produced:
FFT_Test.jpg
I managed to compute the analytic expression to the fourier transform, which is , therefore, I would expect the amplitude of the transform to be T = 1e-9 at f=0 . My conclusion is, therefore, that dividing by the sampling frequency yields the correct result.
So, what am I missing?
Your help will be much appreciated.

Antworten (1)

David Goodmanson
David Goodmanson am 18 Dez. 2018
Bearbeitet: David Goodmanson am 18 Dez. 2018
Hello Dor,
You are right about dividing by fs in this context, but in many other situations you divide by N, the number of fft points.
First of all, your example is pretty seriously undersampled. You can use many more points, and since you are creating your own signal (it is not being supplied to you) there is no need for the outmoded idea of using N = 2^n points. The example below uses 10^4 points.
The time array has spacing delt, where delt = 1/fs by definition. The resulting frequency array has spacing delf, and for an N-point fft, delf = fs/N. This is all consistent with the fundamental rule for the fft,
delt*delf = 1/N (1)
The very use of dt in the expression you have means that you are approximating a continuous integral. The integral becomes Sum{ stuff } * delt. The fft does the sum, and delt stands in for dt. Since delt = 1/fs you divide by fs to get the result.
On the other hand, many times the fft is used to determine discrete fourier coefficients over some finite time interval T. In that case the integral has an extra factor of (1/T) in front. Then the Sum is multiplied by delt/T, which is just 1/N (this is also what you get in the signal processing context). In the example below, taking a complex exponential and dividing by N gives a peak with ampltude 1 as desired.
Note that when N is a power of 10, then from (1) both the time spacing and the frequency spacing can have convenient values. When N is a power of 2, that's not the case. There is no upside to using N = 2^n in these situations.
N = 1e4;
delt = 1e-3;
fs = 1/delt;
t = (-N/2:N/2-1)*delt;
delf = fs/N;
f = (-N/2:N/2-1)*delf; % for fftshifted signal
% fs example
pulsewidth = .1;
y = zeros(size(t));
y(abs(t)<pulsewidth/2) = 1; % rectangular pulse
figure(1)
plot(t,y)
z = fftshift(fft(ifftshift(y))/fs); % shift zero frequency to the center
figure(2)
plot(f,(z))
% N example
f0 = 50;
y = exp(2*pi*i*f0*t);
z = fftshift(fft(y)/N);
figure(3)
plot(f,z)
  2 Kommentare
Dor Assido
Dor Assido am 19 Dez. 2018
Thank you for your answer David!
However, I don’t beleive I fully inderstande what you mean in the part right after equation (1).
Where is the use of delt in my expression? The original signal was created using rectpulse(). Furthermore, how can I distinguish between cases in which I need to normalize by fs and other cases in which I need to normalize by N?
Thanks in advance
David Goodmanson
David Goodmanson am 19 Dez. 2018
Hello Dor,
When you set up your time array,
Ts = 1/fs;
w = 2e-9;
t = -w:Ts:w;
the spacing of that array is Ts = 1/fs, which I called delt.
As far as what to use when, I can't think of anything to add except that in a signal processing context the factor is almost always 1/N.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by