Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: FFT -- sum( v(t))   /=  sum (v(t))
Date: Wed, 4 Nov 2009 19:14:03 +0000 (UTC)
Organization: Xoran Technologies
Lines: 25
Message-ID: <hcsjpr$416$1@fred.mathworks.com>
References: <hcnqim$l20$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257362043 4134 172.30.248.37 (4 Nov 2009 19:14:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Nov 2009 19:14:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:582491


"Travis Bland" <travisbland88@yahoo.com> wrote in message <hcnqim$l20$1@fred.mathworks.com>...
> Hi,
>  I'm taking a course using Matlab, and i'm also doing data analysis for a job. Since i started using Matlab, i thought it might be easier to use than my program written in C++, and i was hoping to check the numbers against eachother.
> I have a file data.dat with two columns, time and voltage. The sum  v(t)^2  should equal the sum of v(f)^2, correct? I should have the same total power in the frequency domain as the time domain? 
> Well i can't get this to prove true. Here's what i tried
> 
> volt_t = data(:,2)
> 
> sum ( v(f)^2 )  --------->
> >> sum(   (fft(volt_t))  .* (fft(volt_t))   )
> ans = 7.6598
> 
> sum(  ( v(f)/ N )^2) ,where N = length volt_t-------->
> >> sum(  abs( (fft(volt_t) / N)  .* (fft(volt_t) / N) ))
> ans = 8.6741e-08

No. To properly normalize the fft to obtain equivalent energies, you must divide by 
sqrt(N), not by N. Try the following for any N:


N=100;
a=rand(1,N);

norm(a), 
norm(fft(a)/sqrt(N)),