Path: news.mathworks.com!not-for-mail
From: "Travis Bland" <travisbland88@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: FFT -- sum( v(t)) /
Date: Tue, 3 Nov 2009 03:35:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 43
Message-ID: <hco8d8$r72$1@fred.mathworks.com>
References: <hcnqim$l20$1@fred.mathworks.com> <18ca1852-949a-41c5-b2dd-0564cad82341@z4g2000prh.googlegroups.com>
Reply-To: "Travis Bland" <travisbland88@yahoo.com>
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 1257219304 27874 172.30.248.37 (3 Nov 2009 03:35:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 03:35:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2073693
Xref: news.mathworks.com comp.soft-sys.matlab:581954


TideMan <mulgor@gmail.com> wrote in message <18ca1852-949a-41c5-b2dd-0564cad82341@z4g2000prh.googlegroups.com>...
> 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)]
> 





Wow, i didn't know you guys would respond so quick!!
Thanks dpb, that outputs the full length.
TideMan
how can i use y to declare y (y=randn(y,1)? It gives an error.  I would normally just figure out what you meant to say... but since i'm new to matlab i can't quite figure out what that code is trying to do.
Also, my data.dat file is 40,004 long. I tried N = 40004 instead of length(volt) but it didn't help any.

Thanks for the quick reply!