Path: news.mathworks.com!not-for-mail
From: "Chen Sagiv" <chensagivron@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Does Matlab do FFT correctly ?
Date: Fri, 2 May 2008 21:26:03 +0000 (UTC)
Organization: Sagiv Enterprises
Lines: 70
Message-ID: <fvg0tb$rjd$1@fred.mathworks.com>
References: <fvfs3j$bnf$1@fred.mathworks.com> <80a6a285-8758-488c-9b98-beed0d03d19e@d45g2000hsc.googlegroups.com>
Reply-To: "Chen Sagiv" <chensagivron@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1209763563 28269 172.30.248.38 (2 May 2008 21:26:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 2 May 2008 21:26:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 805005
Xref: news.mathworks.com comp.soft-sys.matlab:466354


Dear Steven,

I appreciate your answer, but I am afraid that my question 
is still open. When you run my code, you get an imaginary 
part for the transform that is not supposed to be there !!! 
I still have to check your remark regarding the DFT of a 
square pulse being the ratio of two sines. Still, I do not 
think that one may expect getting complex value for the 
Fourier transform. 

Best,

Chen 

"Steven G. Johnson" <stevenj@alum.mit.edu> wrote in message 
<80a6a285-8758-488c-9b98-
beed0d03d19e@d45g2000hsc.googlegroups.com>...
> On May 2, 4:04 pm, "Chen Sagiv" <chensagiv...@gmail.com> 
wrote:
> > We all know that the DFT of a square pulse is a sinc.
> 
> Actually, it's not.  The *Fourier* transform of a square 
pulse is a
> sinc function.  The *discrete* Fourier transform of a 
square pulse is
> something that is close to a sinc, but is not quite the 
same; it is
> the ratio of two sines.  (Just plug a square window into 
the DFT
> formula and sum the geometric series.)
> 
> Your confusion is based on the fact that you don't know 
precisely what
> you are computing.
> 
> > Let's try it:
> >
> > % First we define the square pulse
> > x=-1:0.01:1;
> > f=zeros(size(x));
> > f(x>-0.5 & x<0.5)=1;
> > figure ; plot(x,f);
> >
> > [...]
> >
> > So, it seems that Matlab does correct FFT to signals 
that
> > are not centered about 0, but we have to ifftshift them
> > first.
> 
> This has nothing to do with Matlab, and is a consequence 
of the
> definition of the DFT.  The origin of a DFT is at 1st 
element of the
> input (i.e. the "left" end of the array), with periodic 
boundaries.
> This is totally standard and more-or-less universal among
> implementations of the DFT and FFT algorithms, and is not 
a Matlab
> quirk.
> 
> The fftshift function shifts the origin to the center of 
the array,
> which is where many people expect it (and which is often 
more
> convenient for plotting).
> 
> Regards,
> Steven G. Johnson