Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!z4g2000prh.googlegroups.com!not-for-mail
From: TideMan <mulgor@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: FFT -- sum( v(t)) /= sum (v(t))
Date: Mon, 2 Nov 2009 16:13:54 -0800 (PST)
Organization: http://groups.google.com
Lines: 40
Message-ID: <18ca1852-949a-41c5-b2dd-0564cad82341@z4g2000prh.googlegroups.com>
References: <hcnqim$l20$1@fred.mathworks.com>
NNTP-Posting-Host: 202.78.152.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1257207235 7389 127.0.0.1 (3 Nov 2009 00:13:55 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 3 Nov 2009 00:13:55 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: z4g2000prh.googlegroups.com; posting-host=202.78.152.105; 
	posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
User-Agent: G2/1.0
X-HTTP-Via: 1.1 bc6
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.4) 
	Gecko/20091016 Firefox/3.5.4,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:581937


On Nov 3, 12:39 pm, "Travis Bland" <travisblan...@yahoo.com> wrote:
> 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
>
> sum ( (v(t))^2)----------->>> sum(volt_t .* volt_t)
>
> ans = 0.0035
>
> I notice when i read in the file to volt_t, the precision isn't very high. My values are #*e-06 , and matlab gives   0.0001 or 0.0000. Could this be my issue; if so, how do i fix it? If not, any suggestions on what to do?
>
>  Thanks,
>  Travis

Try this:
N=10000;
y=randn(y,1);
[var(y) sum(abs(fft(y)/N).^2)]