How to calculate energy of the signal at a specific frequency after applying FFT

54 次查看(过去 30 天)
Hi I have a signal X(t) which I want to apply fft to it and then compute the energy at a specific frequency. How can I go about this? Thank you

采纳的回答

Star Strider
Star Strider 2021-11-18
The energy is the amplitude (so with the fft function, since it produces peaks of half amplitude in the negative and positive frequencies after using fftshift with the two-sided fft), multiply the one-sided fft results by 2 to get the actual amplitude at that frequency, and then square that result to get the power, if desired.
.
  4 个评论

请先登录,再进行评论。

更多回答(1 个)

David Goodmanson
David Goodmanson 2021-11-19
编辑:David Goodmanson 2021-12-30
Hello Daniel,
To get the desired result you have to be careful about the number of points, so that an exact number of oscillations occurs in the time window. For y = sin(const*t), an exact number of oscillations means, for example, starting with sine = 0 and ending one point short of sine = 0, because that last sine = 0 belongs at the start of the next repetition of the signal. Anything other than an exact number of oscillations will cause the fft to spill over into adjacent frequencies. That emphatically applies to use of nextpow2 which truncates the signal and almost always results in a nonintegral number of oscillations.
Such spillover is NOT due to floating point error.
So:
n = 1000;
delt = .01;
t = (0:n-1)*delt;
s = sin(2*pi*4*t);
figure(1)
plot(t,s)
grid on
delf = 1/(n*delt);
f = (-n/2:n/2-1)*delf;
y = fftshift(fft(s)/n);
figure(2)
plot(f,abs(y))
grid on
This yeilds two peaks with amplitude 1/2 as should be the case, and no frequency content anywhere else.
For the power, you can square the absolute value of each peak and take the sum
(1/2)^2 + (1/2)^2 = 1/2.
For complex signals, squaring the heights separately has to be done since in general the two peaks do not have the same height. For real signals the abs values of the two peaks are the same, so you can double the positive frequency amplitude to account for negative frequencies. In this example the resulting ampliude is 1, which is the amplitude of the sine wave.
But simply squaring that amplitude to get the power is NOT correct.
You have to toss in a factor of 1/2 because the average value of sin^2 = 1/2.
1^2 * (1/2) = 1/2
All of this applies to a complcated signal if you are looking at just one frequency.

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

标签

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by