Trying to understand the single-sided FFT

221 visualizzazioni (ultimi 30 giorni)
L'O.G.
L'O.G. il 21 Apr 2022
Modificato: Frank il 6 Ago 2025
For a single-sided FFT, is it correct to multiply the FFT by 2, if so why? Also, I have seen some examples that take the absolute value and sometimes not. Would you take the absolute value in taking a single-sided FFT and then the real and imaginary components as in the following example?
fw = 2*abs(fft(ft,nfft)/length(ft));
real_fw = real(fw);
imag_fw = imag(fw);
where nfft is defined in the standard way following MathWorks's example.

Risposte (4)

Bruno Luong
Bruno Luong il 22 Apr 2022
Modificato: Bruno Luong il 22 Apr 2022
Multiplication by 2 for single side is just a convention. To me it doesn't have any solid backup. The convention is stated in page 10-11 here:
It's like "oh, we plot half of the spectrum so otherside of the frequency there is the same amplitude, so just multiply the one we keep by 2".
To respect parseval theorem (Energy conservation), I rather multiply by sqrt(2):
facq = 100;
A=randn(1,21);
N=length(A);
dT = 1/facq;
t = (0:N-1)*dT;
df = facq/N;
Energy_time = sum(A.^2)
Energy_time = 31.8902
EfftA = fft(A)/sqrt(N);
Nh = floor(N/2);
Nh1 = Nh + mod(N,2);
% double-side
dfreq = df*(-Nh:Nh1-1);
doubleside_fftA = fftshift(EfftA);
Energy_ds = sum(abs(doubleside_fftA).^2)
Energy_ds = 31.8902
% single-side
sfreq = df*(0:Nh);
singleeside_fftA = EfftA(1:Nh+1);
singleside_fftA(2:Nh1) = singleeside_fftA(2:Nh1)*sqrt(2);
Energy_ss = sum(abs(singleside_fftA).^2)
Energy_ss = 29.9955
figure
subplot(3,1,1)
plot(t,A);
subplot(3,1,2)
plot(dfreq,abs(doubleside_fftA));
subplot(3,1,3)
plot(sfreq,abs(singleside_fftA));
  2 Commenti
Chunru
Chunru il 22 Apr 2022
> It's like "oh, we plot half of the spectrum so otherside of the frequency there is the > same amplitude, so just multiply the one we keep by 2".
> To respect parseval theorem (Energy conservation), I rather multiply by sqrt(2):
Indeed, in the document it is mentioned that the factor of 2 is for auto/cross spectrum (which is power not amplitude), and hence power of +ve and -ve frequency can add up.
It's true, in Fourier analysis, that one can add up the power at two freq, but not the amplitude at two freq
RH
RH il 28 Nov 2023
Modificato: RH il 28 Nov 2023
It does have a solid foundation. You can show, by direct computation, that the inverse dft signal is a signal of the form (X(k=0) + X(N/2)(-1)^n) + sum_{k=1}^{N/2-1) 2 abs(X(k))cos(2*\pi * f_k n + phase(X(k)))
This immediately shows why you multiply by the factor two. I can post a detailed computation if you are interested, it is not hard.

Accedi per commentare.


Chunru
Chunru il 22 Apr 2022
Assume X(k) = FFT(x(n)).
Then one estimate of Power Spectrum Density (PSD) of x(n) can be given as P(k) = X(k)^2 / N for general complex signal x(n).
For real signal, X(k)=X*(-k), the PSD vlaues at positive and negative frequency are the same. Very often, we concern only positive frequency, the power sensity of both + and - frequencies are combined so that there is a factor of 2.
Therefore, when we are of interested in PSD of real signal, we use P(k) = 2 * X(k)^2 / N (for +ve freq).
  2 Commenti
L'O.G.
L'O.G. il 22 Apr 2022
Modificato: L'O.G. il 22 Apr 2022
Thanks, but I am not interested in and didn't ask about the power spectrum density. You also didn't address everything.
Chunru
Chunru il 22 Apr 2022
It usually make no sense to use 2|X(k)|/M. The P(k) = 2 * X(k)^2 / N is the power spectum density estimation that you may have confused with 2|X(k)|/M.
BTW, I cannot address everything like anyone.

Accedi per commentare.


Walter Roberson
Walter Roberson il 22 Apr 2022
Modificato: Walter Roberson il 22 Apr 2022
For a single-sided FFT, is it correct to multiply the FFT by 2, if so why?
No, it is not.
When you use the analytic fourier transform of a real-valued signal, then the single-sided fourier transform is twice the analytic fourier transform restricted to positive frequencies.
But that is the analytic fourier transform, not the discrete fast fourier transform -- and FFT means "Fast Fourier Transform" not "Fourier Transform".
For the discrete fourier transform, you have to extract the real part of the fft() output before multiplying. https://dsp.stackexchange.com/questions/43366/difference-between-single-sided-and-double-sided-amplitude-spectrum
Would you take the absolute value in taking a single-sided FFT and then the real and imaginary components as in the following example?
No, you would not. abs() is guaranteed not to have any imaginary component afterwards (or, to put it another way, that the imaginary component would be all zero.) There would not be any point in taking the imaginary component of the output of abs()
  3 Commenti
Walter Roberson
Walter Roberson il 22 Apr 2022
I wrote the wrong thing at that point. It is the positive frequency information that you need to extract, which is the first half of the fft() results (possibly omitting the first entry, as that entry corresponds to frequency 0)
2 * F(2:ceil(end/2))
Chunru
Chunru il 22 Apr 2022
The analytic signal is complex. Its Fourier transform of it has two sided specrum defined (but the negative part IS 0).
When dealing with spectrum of a real signal. The spectrum magnitude is symetric on +ve and -ve freq. Therefore one sided spectrum can be used to represented the whole spectrum. If one is talking about power spectrum, then conventially we multiply by 2 on the positive freqency so that the total power (integration under the spectrum) accounts both the +ve and -ve freq. This can be handy when one is to find the total power over certain bandwidth (say f1 to f2). The integration of P(f) over f1 to f2 give the signal power over that freq range. This is meaningful because in analysing real signal, we rarely talking about -ve freq.

Accedi per commentare.


Frank
Frank il 5 Ago 2025
Modificato: Frank il 6 Ago 2025
The DFT is generally poorly understood. The DeweSoft article is good, but goes immediately into auto- and cross-spectra, which will make most casual readers glaze over, so I offer this explanation without any equations.
Note the emphis is on Discrete - it is of no consequence whether it's computed in a Fast way or not. The DFT is a fundamentally different animal from its continuous time counterpart (CFT) and that distinction is most profound when considering a continuous sine or cosine (CW) signal. In the CFT, the value at the signal frequency is infinite - it's the Dirac delta function times the amplitude of the wave, and can't even be plotted on a graph! So, clearly it's not useful to try to interpret the DFT to make it behave like the CFT, and that's the source of most of the confusion.
Now it's true that the amplitude of the DFT at the signal frequency is proportional to the number of samples (N) and the question seems to be whether that constant should be taken as 1 or 2. What it does prove, however, is that the DFT approaches the CFT as N goes to infinity, but most of us can't wait that long for our data and we must make do with the limitations of the finite DFT.
If you integrate the CFT over a small interval around the signal frequency, you get the amplitude of the CW signal, because the integral of the Dirac delta is 1.
Therefore one interpretation of the DFT is to consider each frequency bin to represent the AVERAGE amplitude in that bin, which aligns nicely with the CFT - and then whether it's 1 or 2 becomes important. The answer is that all FTs, whether CFT or DFT are defined over all frequences from minus to plus infinity, but there are no practical instruments, which measure negative frequencies. I've never seen a frequency counter, which gives negative values! So, do we simply brush the negative ones under the carpet? No, of course not. We make use of a very important property of all real-world signals: they are indeed real, and this means that the FT has an important symmetry. The transform for negative frequencies is the conjugate of that for the positive ones. Therefore, the negative part contains no different information and could be ignored. But you need to acknowledge that you have ignored them.
Going back to the case of a CW signal of amplitude A, the the magnitude of the DFT at both the negative and positive signal frequencies is N*A/2, so simply discarding the negative ones and dividing by N would give an average amplitude of A/2. Therefore, at the same time that we discard the negative part, we must double the remaining positive part in order to maintain our interpretation that the DFT represents the average amplitude in each bin. And you can do the same for the CFT.
If on the other hand, you prefer to interpret the FT to represent energy instead of amplitude, the answer is different. The energy is proportional to the square of the amplitude and in the CFT, the integral of the Dirac delta squared does NOT converge! And that's how it should be; an infinitely long CW has infinite energy. But it has finite power! And you get that by dividing the energy by the duration of the signal. In the CFT that's Infinity/Infinity, but that's OK because it converges to A^2/2.
To get the same answer in the DFT, we need to double the positive part and divide by N (to get the amplitude), then square it and divide by 2 (to get the power). But hey, that's the same as multiplying the positive part by √2 so that you get the power when squaring it.
The bottom line is that you multiply the DFT by 2/N or √2/N depending on how you want to interpret the answer: do you want amplitude or power?

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by