0

What is the correct way to sum a range of frequencies in an FFT? I heard that I had to sum the squares after multiplying by the frequency.

Here's what I'm doing:

 freqDomain = abs(fft(signal.*window)); %FFT
 freqDomain = freqDomain(2:(windowSize/2+1)); %We're only interested in the first half

 freqDomain = freqDomain .* (1:windowSize/2); % Convert to PSD

 lowFreq = freqDomain(lowFreqPeriod(2):lowFreqPeriod(1)); %Extract the range we need
 highFreq = freqDomain(highFreqPeriod(2):highFreqPeriod(1));

 lowFreq = sum(lowFreqDomain .^ 2); % sum of squares
 highFreq = sum(highFreqDomain .^ 2);

The code works, and I'm getting what I think is a decent result, but is it mathmatically right?

flag
Anon, I'm afraid MathOverflow is not for checking people's code. – S. Carnahan Mar 24 2011 at 4:31
I only included the code to try and be helpful. I just wanted to know if it's correct to sum the squares of the fft bins. – Anon Mar 24 2011 at 12:06

closed as off topic by Igor Rivin, S. Carnahan Mar 24 2011 at 4:29

Browse other questions tagged or ask your own question.