<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790</link>
    <title>MATLAB Central Newsreader - FFT -- sum( v(t))   /=  sum (v(t))</title>
    <description>Feed for thread: FFT -- sum( v(t))   /=  sum (v(t))</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 02 Nov 2009 23:39:02 -0500</pubDate>
      <title>FFT -- sum( v(t))   /=  sum (v(t))</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#691605</link>
      <author>Travis Bland</author>
      <description>Hi,&lt;br&gt;
&amp;nbsp;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.&lt;br&gt;
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? &lt;br&gt;
Well i can't get this to prove true. Here's what i tried&lt;br&gt;
&lt;br&gt;
volt_t = data(:,2)&lt;br&gt;
&lt;br&gt;
sum ( v(f)^2 )  ---------&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; sum(   (fft(volt_t))  .* (fft(volt_t))   )&lt;br&gt;
ans = 7.6598&lt;br&gt;
&lt;br&gt;
sum(  ( v(f)/ N )^2) ,where N = length volt_t--------&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; sum(  abs( (fft(volt_t) / N)  .* (fft(volt_t) / N) ))&lt;br&gt;
ans = 8.6741e-08&lt;br&gt;
&lt;br&gt;
sum ( (v(t))^2)-----------&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; sum(volt_t .* volt_t)&lt;br&gt;
ans = 0.0035&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
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?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;Thanks,&lt;br&gt;
&amp;nbsp;Travis</description>
    </item>
    <item>
      <pubDate>Mon, 02 Nov 2009 23:56:20 -0500</pubDate>
      <title>Re: FFT -- sum( v(t))   /=  sum (v(t))</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#691606</link>
      <author>dpb</author>
      <description>Travis Bland wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
...&lt;br&gt;
&amp;gt; I notice when i read in the file to volt_t, the precision isn't very&lt;br&gt;
&amp;gt; high. My values are #*e-06 , and matlab gives   0.0001 or 0.0000.&lt;br&gt;
&amp;gt; Could this be my issue; if so, how do i fix it? If not, any&lt;br&gt;
&amp;gt; suggestions on what to do?&lt;br&gt;
&amp;gt; &lt;br&gt;
ML uses default double for internal representation irrespective of what &lt;br&gt;
the command window display format is.&lt;br&gt;
&lt;br&gt;
Try&lt;br&gt;
&lt;br&gt;
format long&lt;br&gt;
&lt;br&gt;
or&lt;br&gt;
&lt;br&gt;
format long e&lt;br&gt;
&lt;br&gt;
to see full internal precision.&lt;br&gt;
&lt;br&gt;
doc format   % for more info&lt;br&gt;
&lt;br&gt;
As for the fft normalization, w/ correct normalization you should find &lt;br&gt;
all the energy, yes.&lt;br&gt;
&lt;br&gt;
--</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 00:13:54 -0500</pubDate>
      <title>Re: FFT -- sum( v(t)) /</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#691610</link>
      <author>TideMan</author>
      <description>On Nov 3, 12:39&#160;pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &#160;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.&lt;br&gt;
&amp;gt; I have a file data.dat with two columns, time and voltage. The sum &#160;v(t)^2 &#160;should equal the sum of v(f)^2, correct? I should have the same total power in the frequency domain as the time domain?&lt;br&gt;
&amp;gt; Well i can't get this to prove true. Here's what i tried&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; volt_t = data(:,2)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; sum ( v(f)^2 ) &#160;---------&amp;gt;&amp;gt;&amp;gt; sum( &#160; (fft(volt_t)) &#160;.* (fft(volt_t)) &#160; )&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans = 7.6598&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; sum( &#160;( v(f)/ N )^2) ,where N = length volt_t--------&amp;gt;&amp;gt;&amp;gt; sum( &#160;abs( (fft(volt_t) / N) &#160;.* (fft(volt_t) / N) ))&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans = 8.6741e-08&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; sum ( (v(t))^2)-----------&amp;gt;&amp;gt;&amp;gt; sum(volt_t .* volt_t)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans = 0.0035&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 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 &#160; 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?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &#160;Thanks,&lt;br&gt;
&amp;gt; &#160;Travis&lt;br&gt;
&lt;br&gt;
Try this:&lt;br&gt;
N=10000;&lt;br&gt;
y=randn(y,1);&lt;br&gt;
[var(y) sum(abs(fft(y)/N).^2)]</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 03:35:04 -0500</pubDate>
      <title>Re: FFT -- sum( v(t)) /</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#691626</link>
      <author>Travis Bland</author>
      <description>TideMan &amp;lt;mulgor@gmail.com&amp;gt; wrote in message &amp;lt;18ca1852-949a-41c5-b2dd-0564cad82341@z4g2000prh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On Nov 3, 12:39?pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; ?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.&lt;br&gt;
&amp;gt; &amp;gt; 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?&lt;br&gt;
&amp;gt; &amp;gt; Well i can't get this to prove true. Here's what i tried&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; volt_t = data(:,2)&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; sum ( v(f)^2 ) ?---------&amp;gt;&amp;gt;&amp;gt; sum( ? (fft(volt_t)) ?.* (fft(volt_t)) ? )&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; ans = 7.6598&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; sum( ?( v(f)/ N )^2) ,where N = length volt_t--------&amp;gt;&amp;gt;&amp;gt; sum( ?abs( (fft(volt_t) / N) ?.* (fft(volt_t) / N) ))&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; ans = 8.6741e-08&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; sum ( (v(t))^2)-----------&amp;gt;&amp;gt;&amp;gt; sum(volt_t .* volt_t)&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; ans = 0.0035&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; 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?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; ?Thanks,&lt;br&gt;
&amp;gt; &amp;gt; ?Travis&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Try this:&lt;br&gt;
&amp;gt; N=10000;&lt;br&gt;
&amp;gt; y=randn(y,1);&lt;br&gt;
&amp;gt; [var(y) sum(abs(fft(y)/N).^2)]&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Wow, i didn't know you guys would respond so quick!!&lt;br&gt;
Thanks dpb, that outputs the full length.&lt;br&gt;
TideMan&lt;br&gt;
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.&lt;br&gt;
Also, my data.dat file is 40,004 long. I tried N = 40004 instead of length(volt) but it didn't help any.&lt;br&gt;
&lt;br&gt;
Thanks for the quick reply!</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 06:21:32 -0500</pubDate>
      <title>Re: FFT -- sum( v(t)) /</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#691644</link>
      <author>TideMan</author>
      <description>On Nov 3, 4:35&#160;pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; TideMan &amp;lt;mul...@gmail.com&amp;gt; wrote in message &amp;lt;18ca1852-949a-41c5-b2dd-0564cad82...@z4g2000prh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; On Nov 3, 12:39?pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ?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.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 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?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Well i can't get this to prove true. Here's what i tried&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; volt_t = data(:,2)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; sum ( v(f)^2 ) ?---------&amp;gt;&amp;gt;&amp;gt; sum( ? (fft(volt_t)) ?.* (fft(volt_t)) ? )&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ans = 7.6598&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; sum( ?( v(f)/ N )^2) ,where N = length volt_t--------&amp;gt;&amp;gt;&amp;gt; sum( ?abs( (fft(volt_t) / N) ?.* (fft(volt_t) / N) ))&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ans = 8.6741e-08&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; sum ( (v(t))^2)-----------&amp;gt;&amp;gt;&amp;gt; sum(volt_t .* volt_t)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ans = 0.0035&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 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?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ?Thanks,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ?Travis&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Try this:&lt;br&gt;
&amp;gt; &amp;gt; N=10000;&lt;br&gt;
&amp;gt; &amp;gt; y=randn(y,1);&lt;br&gt;
&amp;gt; &amp;gt; [var(y) sum(abs(fft(y)/N).^2)]&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Wow, i didn't know you guys would respond so quick!!&lt;br&gt;
&amp;gt; Thanks dpb, that outputs the full length.&lt;br&gt;
&amp;gt; TideMan&lt;br&gt;
&amp;gt; how can i use y to declare y (y=randn(y,1)? It gives an error. &#160;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.&lt;br&gt;
&amp;gt; Also, my data.dat file is 40,004 long. I tried N = 40004 instead of length(volt) but it didn't help any.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks for the quick reply!&lt;br&gt;
&lt;br&gt;
OOps&lt;br&gt;
Typo.  It should have read:&lt;br&gt;
y=randn(N,1);</description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 16:24:03 -0500</pubDate>
      <title>Re: FFT -- sum( v(t)) /</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#692102</link>
      <author>Travis Bland</author>
      <description>TideMan &amp;lt;mulgor@gmail.com&amp;gt; wrote in message &amp;lt;ab1631de-4e0f-4f32-88ef-7afb8935a075@f1g2000prf.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On Nov 3, 4:35?pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; TideMan &amp;lt;mul...@gmail.com&amp;gt; wrote in message &amp;lt;18ca1852-949a-41c5-b2dd-0564cad82...@z4g2000prh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; On Nov 3, 12:39?pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; ?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.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; 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?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Well i can't get this to prove true. Here's what i tried&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; volt_t = data(:,2)&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; sum ( v(f)^2 ) ?---------&amp;gt;&amp;gt;&amp;gt; sum( ? (fft(volt_t)) ?.* (fft(volt_t)) ? )&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; ans = 7.6598&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; sum( ?( v(f)/ N )^2) ,where N = length volt_t--------&amp;gt;&amp;gt;&amp;gt; sum( ?abs( (fft(volt_t) / N) ?.* (fft(volt_t) / N) ))&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; ans = 8.6741e-08&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; sum ( (v(t))^2)-----------&amp;gt;&amp;gt;&amp;gt; sum(volt_t .* volt_t)&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; ans = 0.0035&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; 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?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; ?Thanks,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; ?Travis&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Try this:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; N=10000;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; y=randn(y,1);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; [var(y) sum(abs(fft(y)/N).^2)]&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Wow, i didn't know you guys would respond so quick!!&lt;br&gt;
&amp;gt; &amp;gt; Thanks dpb, that outputs the full length.&lt;br&gt;
&amp;gt; &amp;gt; TideMan&lt;br&gt;
&amp;gt; &amp;gt; 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.&lt;br&gt;
&amp;gt; &amp;gt; Also, my data.dat file is 40,004 long. I tried N = 40004 instead of length(volt) but it didn't help any.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thanks for the quick reply!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; OOps&lt;br&gt;
&amp;gt; Typo.  It should have read:&lt;br&gt;
&amp;gt; y=randn(N,1);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
alright, so that gives me the same value each time. But I'm not quite sure what it's doing. I fed my data into y&lt;br&gt;
N= 40004;&lt;br&gt;
y=data(:,2);&lt;br&gt;
[var(y) sum(abs(fft(y)/N).^2)]&lt;br&gt;
&lt;br&gt;
but that doesn't give me the same values.&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&amp;nbsp;&amp;nbsp;1.0e-007 *&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.3966                              0.4485&lt;br&gt;
&lt;br&gt;
What did i do wrong? </description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 18:51:31 -0500</pubDate>
      <title>Re: FFT -- sum( v(t)) /</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#692150</link>
      <author>TideMan</author>
      <description>On Nov 5, 5:24&#160;am, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; TideMan &amp;lt;mul...@gmail.com&amp;gt; wrote in message &amp;lt;ab1631de-4e0f-4f32-88ef-7afb8935a...@f1g2000prf.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; On Nov 3, 4:35?pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; TideMan &amp;lt;mul...@gmail.com&amp;gt; wrote in message &amp;lt;18ca1852-949a-41c5-b2dd-0564cad82...@z4g2000prh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; On Nov 3, 12:39?pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; ?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.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; 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?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Well i can't get this to prove true. Here's what i tried&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; volt_t = data(:,2)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; sum ( v(f)^2 ) ?---------&amp;gt;&amp;gt;&amp;gt; sum( ? (fft(volt_t)) ?.* (fft(volt_t)) ? )&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; ans = 7.6598&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; sum( ?( v(f)/ N )^2) ,where N = length volt_t--------&amp;gt;&amp;gt;&amp;gt; sum( ?abs( (fft(volt_t) / N) ?.* (fft(volt_t) / N) ))&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; ans = 8.6741e-08&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; sum ( (v(t))^2)-----------&amp;gt;&amp;gt;&amp;gt; sum(volt_t .* volt_t)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; ans = 0.0035&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; 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?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; ?Thanks,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; ?Travis&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Try this:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; N=10000;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; y=randn(y,1);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; [var(y) sum(abs(fft(y)/N).^2)]&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Wow, i didn't know you guys would respond so quick!!&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks dpb, that outputs the full length.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; TideMan&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 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.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Also, my data.dat file is 40,004 long. I tried N = 40004 instead of length(volt) but it didn't help any.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks for the quick reply!&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; OOps&lt;br&gt;
&amp;gt; &amp;gt; Typo. &#160;It should have read:&lt;br&gt;
&amp;gt; &amp;gt; y=randn(N,1);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; alright, so that gives me the same value each time. But I'm not quite sure what it's doing. I fed my data into y&lt;br&gt;
&amp;gt; N= 40004;&lt;br&gt;
&amp;gt; y=data(:,2);&lt;br&gt;
&amp;gt; [var(y) sum(abs(fft(y)/N).^2)]&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; but that doesn't give me the same values.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans =&lt;br&gt;
&amp;gt; &#160; 1.0e-007 *&lt;br&gt;
&amp;gt; &#160; &#160; 0.3966 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;0.4485&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; What did i do wrong?&lt;br&gt;
&lt;br&gt;
It assumes the mean is zero.&lt;br&gt;
Do this first:&lt;br&gt;
y=detrend(y,0);</description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 19:14:03 -0500</pubDate>
      <title>Re: FFT -- sum( v(t))   /=  sum (v(t))</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#692160</link>
      <author>Matt </author>
      <description>&quot;Travis Bland&quot; &amp;lt;travisbland88@yahoo.com&amp;gt; wrote in message &amp;lt;hcnqim$l20$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;  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.&lt;br&gt;
&amp;gt; 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? &lt;br&gt;
&amp;gt; Well i can't get this to prove true. Here's what i tried&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; volt_t = data(:,2)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; sum ( v(f)^2 )  ---------&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; sum(   (fft(volt_t))  .* (fft(volt_t))   )&lt;br&gt;
&amp;gt; ans = 7.6598&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; sum(  ( v(f)/ N )^2) ,where N = length volt_t--------&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; sum(  abs( (fft(volt_t) / N)  .* (fft(volt_t) / N) ))&lt;br&gt;
&amp;gt; ans = 8.6741e-08&lt;br&gt;
&lt;br&gt;
No. To properly normalize the fft to obtain equivalent energies, you must divide by &lt;br&gt;
sqrt(N), not by N. Try the following for any N:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
N=100;&lt;br&gt;
a=rand(1,N);&lt;br&gt;
&lt;br&gt;
norm(a), &lt;br&gt;
norm(fft(a)/sqrt(N)),</description>
    </item>
    <item>
      <pubDate>Thu, 05 Nov 2009 01:12:09 -0500</pubDate>
      <title>Re: FFT -- sum( v(t)) /</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#692247</link>
      <author>Greg Heath</author>
      <description>On Nov 2, 6:39&#160;pm, &quot;Travis Bland&quot; &amp;lt;travisblan...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &#160;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.&lt;br&gt;
&amp;gt; I have a file data.dat with two columns, time and voltage. The sum &#160;v(t)^2 &#160;should equal the sum of v(f)^2, correct? I should have the same total power in the frequency domain as the time domain?&lt;br&gt;
&amp;gt; Well i can't get this to prove true. Here's what i tried&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; volt_t = data(:,2)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; sum ( v(f)^2 ) &#160;---------&amp;gt;&amp;gt;&amp;gt; sum( &#160; (fft(volt_t)) &#160;.* (fft(volt_t)) &#160; )&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans = 7.6598&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; sum( &#160;( v(f)/ N )^2) ,where N = length volt_t--------&amp;gt;&amp;gt;&amp;gt; sum( &#160;abs( (fft(volt_t) / N) &#160;.* (fft(volt_t) / N) ))&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans = 8.6741e-08&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; sum ( (v(t))^2)-----------&amp;gt;&amp;gt;&amp;gt; sum(volt_t .* volt_t)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans = 0.0035&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 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 &#160; 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?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &#160;Thanks,&lt;br&gt;
&amp;gt; &#160;Travis&lt;br&gt;
&lt;br&gt;
Take a look at&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://groups.google.com/group/comp.soft-sys.matlab/msg/2222327db2ea7f51?hl=en&quot;&gt;http://groups.google.com/group/comp.soft-sys.matlab/msg/2222327db2ea7f51?hl=en&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
    <item>
      <pubDate>Thu, 05 Nov 2009 03:05:19 -0500</pubDate>
      <title>Re: FFT -- sum( v(t))   /=  sum (v(t))</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264790#692268</link>
      <author>Travis Bland</author>
      <description>&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Matt &quot; &amp;lt;xys@whatever.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; No. To properly normalize the fft to obtain equivalent energies, you must divide by &lt;br&gt;
&amp;gt; sqrt(N), not by N. Try the following for any N:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; N=100;&lt;br&gt;
&amp;gt; a=rand(1,N);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; norm(a), &lt;br&gt;
&amp;gt; norm(fft(a)/sqrt(N)),&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
THANKYOU MATT!! This is what i was looking for. I wondered if it just wasn't normalized correctly. &lt;br&gt;
I had no clue what was going on in the other methods, i don't understand the need for all of the functions... i thought this was a simple thing... sum v(t) = sum v(f)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
But interestingly enough, i wrote my own function to sum the two arrays, and when i used this code... i got the two values to be the same... and i normalized using N. There must be something going on internally somewhere that i don't understand.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
load std000.txt&lt;br&gt;
volt = std000(:,2);&lt;br&gt;
v_s = 0;&lt;br&gt;
for n = 1:40004&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;v_s = (volt(n).* volt(n)) + v_s ;    %sum of v(t)&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
v_f = (fft(volt));&lt;br&gt;
v_f_s = 0;&lt;br&gt;
&lt;br&gt;
for b = 1:40004&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;v_f_s = v_f_s + (abs((v_f(b) .* v_f(b))/ 40004));&lt;br&gt;
end&lt;br&gt;
v_s    %sum of v(t)&lt;br&gt;
v_f_s   % sum of v(f)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
but thanks to everyone</description>
    </item>
  </channel>
</rss>

