Calculating energy
Afficher commentaires plus anciens
Hi,
I would appreciate your help and suggestions. I know this is a silly question for most of the readers, but this has been bugging me for sometime. I generated a PSD of a signal using spectrogram command (matlab signal processing toolbox). I used a 250 ms window. to calculate the energy for a frequency band in a certain time window, can i simply add up the power values of the individual frequencies or should i multiply power values * frequency then add up the results .. or ... for example: WINDOW1: (freq 1 Hz power 20) (freq 2Hz power 20) (freq 3 Hz power 15) is the energy of 1-3 Hz band in WINDOW1 is 20 + 20 + 15 or is it 1 X 20 + 2 X 20 + 3 X 15 ... Thanks a lot.
Réponse acceptée
Plus de réponses (4)
Wayne King
le 20 Mar 2012
Hi Raf, you should do this:
should i multiply power values * frequency then add up the result
BUT you want to multiply by the width in frequency, or your delta f. What is the different in Hz between adjacent DFT bins? You can use diff() on your frequency vector to get that info. Multiplying your power estimates by that delta f and summing the result approximates the integral under the PSD.
I don't know how long this vector is in samples (250 msec), but you can check yourself by just using the avgpower method on a single 250 msec sample
x = randn(1e3,1);
psdestx = psd(spectrum.periodogram,x,'Fs',1,'NFFT',length(x));
% power in frequency interval 1/4 to 1/2
pwr = avgpower(psdestx,[1/4 1/2]);
It's probably more meaningful to take the frequency interval width into account as you suggest in your second option.
For example:
t = 0:0.001:1-0.001;
x = 2*cos(2*pi*100*t);
psdestx = psd(spectrum.periodogram,x,'Fs',1e3,'NFFT',length(x));
pwr = avgpower(psdestx);
Answer is 4/2 as you would expect, now just look in the range around 100 Hz.
pwr = avgpower(psdestx,[95 105])
Still 2, because all the power is there!
2 commentaires
Dr. Seis
le 20 Mar 2012
But that is average power... the energy in a cosine wave is dependent on how long the cosine wave signal is. The energy (in the time domain) is equal to the integral of the amplitudes squared... therefore the energy in your signal will increase more and more as you make your "t" longer and longer. That means that the frequency domain amplitude at 100Hz (in your example) gets bigger and bigger... remember Parseval's theorem!
Wayne King
le 20 Mar 2012
Exactly, I was assuming the OP was really interested in average power.
Raf K
le 20 Mar 2012
0 votes
3 commentaires
Wayne King
le 20 Mar 2012
Then you can certainly just sum the powers at at the respective frequencies.
Raf K
le 20 Mar 2012
Dr. Seis
le 21 Mar 2012
Energy is NOT the sum of power. Power has units of energy per second (in the time domain) and energy per Hertz (in the frequency domain).
Raf K
le 24 Mar 2012
0 votes
Mouna Bouhachem
le 15 Sep 2021
0 votes
Thanks Very Much!
Catégories
En savoir plus sur Parametric Spectral Estimation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!