<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161287</link>
    <title>MATLAB Central Newsreader - integrating with FFT</title>
    <description>Feed for thread: integrating with FFT</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>Thu, 27 Dec 2007 01:56:07 -0500</pubDate>
      <title>integrating with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161287#407271</link>
      <author>Paul </author>
      <description>You can integrate in the frequency domain by dividing the&lt;br&gt;
complex FFT by iw.  I've been trying this but to no avail&lt;br&gt;
since I seem to be getting hung up on the symmetry of the&lt;br&gt;
FFT around the nyquist.&lt;br&gt;
&lt;br&gt;
For example:&lt;br&gt;
&lt;br&gt;
x = 1:10;&lt;br&gt;
&lt;br&gt;
and the integral of x is trivial.&lt;br&gt;
&lt;br&gt;
But I try to do this via fft, division by iw and then&lt;br&gt;
inverse fft and end up with junk.   I recall seeing this&lt;br&gt;
done someplace before but I checked the archives and found&lt;br&gt;
nothing.&lt;br&gt;
&lt;br&gt;
Can anybody show how this is done!   </description>
    </item>
    <item>
      <pubDate>Thu, 27 Dec 2007 04:09:26 -0500</pubDate>
      <title>Re: integrating with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161287#407281</link>
      <author>Greg Heath</author>
      <description>On Dec 26, 8:56=A0pm, &quot;Paul &quot; &amp;lt;p...@ceri.memphis.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; You can integrate in the frequency domain by dividing the&lt;br&gt;
&amp;gt; complex FFT by iw. =A0I've been trying this but to no avail&lt;br&gt;
&amp;gt; since I seem to be getting hung up on the symmetry of the&lt;br&gt;
&amp;gt; FFT around the nyquist.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; For example:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; x =3D 1:10;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; and the integral of x is trivial.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; But I try to do this via fft, division by iw and then&lt;br&gt;
&amp;gt; inverse fft and end up with junk. =A0 I recall seeing this&lt;br&gt;
&amp;gt; done someplace before but I checked the archives and found&lt;br&gt;
&amp;gt; nothing.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Can anybody show how this is done!&lt;br&gt;
&lt;br&gt;
The answer is probably in the details of your code. Post it&lt;br&gt;
and useful advice will probably follow.&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
    <item>
      <pubDate>Thu, 27 Dec 2007 08:49:58 -0500</pubDate>
      <title>Re: integrating with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161287#407304</link>
      <author>Greg Heath</author>
      <description>On Dec 26, 8:56 pm, &quot;Paul &quot; &amp;lt;p...@ceri.memphis.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; You can integrate in the frequency domain by dividing the&lt;br&gt;
&amp;gt; complex FFT by iw.&lt;br&gt;
&lt;br&gt;
With caveats.&lt;br&gt;
&lt;br&gt;
To be consistent with the periodic DFT, make the following&lt;br&gt;
assumptions&lt;br&gt;
&lt;br&gt;
F(iw) = INT(0,T){ dt f(t)*exp(-iwt) },&lt;br&gt;
G(iw) = INT(0,T){ dt g(t)*exp(-iwt) },&lt;br&gt;
g(t) = g(0) + INT(0,t){dt f(t) },&lt;br&gt;
&lt;br&gt;
Since f(t) = g'(t), integrating by parts yields&lt;br&gt;
&lt;br&gt;
F(iw) = INT(0,T){ dt g'(t)*exp(-iwt) }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= g(T)*exp(-iwT)- g(0) + iw*G(iw)&lt;br&gt;
&lt;br&gt;
Since F = iw*G must hold for all w, the following&lt;br&gt;
conditions are required&lt;br&gt;
&lt;br&gt;
1. g(0) = 0&lt;br&gt;
2. g(T) = F(0) = 0&lt;br&gt;
&lt;br&gt;
For both the sampled CFT and the DFT, the division by&lt;br&gt;
iw at w = 0 is problematical. Therefore,&lt;br&gt;
&lt;br&gt;
3. The point w = 0 should be excluded by assuming&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;G(0) = 0 = F(0) .&lt;br&gt;
&lt;br&gt;
&amp;gt; I've been trying this but to no avail&lt;br&gt;
&amp;gt; since I seem to be getting hung up on the symmetry of the&lt;br&gt;
&amp;gt; FFT around the nyquist.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; For example:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; x = 1:10;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; and the integral of x is trivial.&lt;br&gt;
&lt;br&gt;
However, the average value of x is not zero.&lt;br&gt;
&lt;br&gt;
&amp;gt; But I try to do this via fft, division by iw and then&lt;br&gt;
&amp;gt; inverse fft and end up with junk.   I recall seeing this&lt;br&gt;
&amp;gt; done someplace before but I checked the archives and found&lt;br&gt;
&amp;gt; nothing.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Can anybody show how this is done!&lt;br&gt;
&lt;br&gt;
N = 10&lt;br&gt;
dt = 1&lt;br&gt;
t = (0:N-1)*dt;&lt;br&gt;
x = t+1;            % need to subtract the mean value&lt;br&gt;
m = mean(x)   % m = 99/18&lt;br&gt;
x = x - mean(x);&lt;br&gt;
y = ((t+1).^2/2 - (99/18)*t -1/2;&lt;br&gt;
&lt;br&gt;
T = N*dt&lt;br&gt;
df = 1/T&lt;br&gt;
f = (0:N-1)*df;&lt;br&gt;
X = fft(x);&lt;br&gt;
Y = fft(y);&lt;br&gt;
&lt;br&gt;
P = floor((N+1)/2)&lt;br&gt;
fP = (P-1)*df&lt;br&gt;
fb = f-fP;&lt;br&gt;
Xb = fftshift(X);&lt;br&gt;
Yb = fftshift(Y);&lt;br&gt;
&lt;br&gt;
iwb = i*2*pi*fb;&lt;br&gt;
&lt;br&gt;
%Since iwb(P) = 0, using Xb./iwb is problematic.&lt;br&gt;
% Instead, investigate&lt;br&gt;
&lt;br&gt;
Err = Yb-iwb.*Xb;&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
    <item>
      <pubDate>Thu, 14 Feb 2008 05:16:14 -0500</pubDate>
      <title>Re: integrating with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161287#414969</link>
      <author>Greg Heath</author>
      <description>On Dec 27 2007, 3:49=A0am, Greg Heath &amp;lt;he...@alumni.brown.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; On Dec 26, 8:56 pm, &quot;Paul &quot; &amp;lt;p...@ceri.memphis.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; You can integrate in the frequency domain by dividing the&lt;br&gt;
&amp;gt; &amp;gt; complex FFT by iw.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; With caveats.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; To be consistent with the periodic DFT, make the following&lt;br&gt;
&amp;gt; assumptions&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; F(iw) =3D INT(0,T){ dt f(t)*exp(-iwt) },&lt;br&gt;
&amp;gt; G(iw) =3D INT(0,T){ dt g(t)*exp(-iwt) },&lt;br&gt;
&amp;gt; g(t) =3D g(0) + INT(0,t){dt f(t) },&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Since f(t) =3D g'(t), integrating by parts yields&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; F(iw) =3D INT(0,T){ dt g'(t)*exp(-iwt) }&lt;br&gt;
&amp;gt; =A0 =A0 =A0 =A0 =A0 =3D g(T)*exp(-iwT)- g(0) + iw*G(iw)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Since F =3D iw*G must hold for all w, the following&lt;br&gt;
&amp;gt; conditions are required&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 1. g(0) =3D 0&lt;br&gt;
&amp;gt; 2. g(T) =3D F(0) =3D 0&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; For both the sampled CFT and the DFT, the division by&lt;br&gt;
&amp;gt; iw at w =3D 0 is problematical. Therefore,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 3. The point w =3D 0 should be excluded by assuming&lt;br&gt;
&amp;gt; =A0 =A0 G(0) =3D 0 =3D F(0) .&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I've been trying this but to no avail&lt;br&gt;
&amp;gt; &amp;gt; since I seem to be getting hung up on the symmetry of the&lt;br&gt;
&amp;gt; &amp;gt; FFT around the nyquist.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; For example:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; x =3D 1:10;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; and the integral of x is trivial.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; However, the average value of x is not zero.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; But I try to do this via fft, division by iw and then&lt;br&gt;
&amp;gt; &amp;gt; inverse fft and end up with junk. =A0 I recall seeing this&lt;br&gt;
&amp;gt; &amp;gt; done someplace before but I checked the archives and found&lt;br&gt;
&amp;gt; &amp;gt; nothing.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Can anybody show how this is done!&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; N =3D 10&lt;br&gt;
&amp;gt; dt =3D 1&lt;br&gt;
&amp;gt; t =3D (0:N-1)*dt;&lt;br&gt;
&amp;gt; x =3D t+1; =A0 =A0 =A0 =A0 =A0 =A0% need to subtract the mean value&lt;br&gt;
&amp;gt; m =3D mean(x) =A0 % m =3D 99/18&lt;br&gt;
&amp;gt; x =3D x - mean(x);&lt;br&gt;
&amp;gt; y =3D ((t+1).^2/2 - (99/18)*t -1/2;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; T =3D N*dt&lt;br&gt;
&amp;gt; df =3D 1/T&lt;br&gt;
&amp;gt; f =3D (0:N-1)*df;&lt;br&gt;
&amp;gt; X =3D fft(x);&lt;br&gt;
&amp;gt; Y =3D fft(y);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; P =3D floor((N+1)/2)&lt;br&gt;
&amp;gt; fP =3D (P-1)*df&lt;br&gt;
&amp;gt; fb =3Df-fP;&lt;br&gt;
&lt;br&gt;
Correction&lt;br&gt;
&lt;br&gt;
Q  =3D ceil((N+1)/2)&lt;br&gt;
fQ =3D (Q-1)*df&lt;br&gt;
fb  =3D f-fQ;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; Xb =3D fftshift(X);&lt;br&gt;
&amp;gt; Yb =3D fftshift(Y);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; iwb =3D i*2*pi*fb;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; %Since iwb(P) =3D 0, using Xb./iwb is problematic.&lt;br&gt;
&lt;br&gt;
Since iwb(Q) =3D 0, using Xb./iwb is problematic.&lt;br&gt;
&lt;br&gt;
&amp;gt; % Instead, investigate&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Err =3D Yb-iwb.*Xb;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Hope this helps.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Greg</description>
    </item>
  </channel>
</rss>

