Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!i76g2000hsf.googlegroups.com!not-for-mail
From: "Steven G. Johnson" <stevenj@alum.mit.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Does Matlab do FFT correctly ?
Date: Fri, 2 May 2008 14:47:01 -0700 (PDT)
Organization: http://groups.google.com
Lines: 28
Message-ID: <e4eb82ac-4ea7-49b7-8cdd-aa427d8b064b@i76g2000hsf.googlegroups.com>
References: <fvfs3j$bnf$1@fred.mathworks.com> <80a6a285-8758-488c-9b98-beed0d03d19e@d45g2000hsc.googlegroups.com> 
NNTP-Posting-Host: 18.87.0.80
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1209764821 9123 127.0.0.1 (2 May 2008 21:47:01 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 2 May 2008 21:47:01 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: i76g2000hsf.googlegroups.com; posting-host=18.87.0.80; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; 
	rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:466358


On May 2, 5:26 pm, "Chen Sagiv" <chensagiv...@gmail.com> wrote:
> 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.

Sorry, I thought I had been clear.  Your square pulse is not centered
at the origin (the origin for the DFT is *not* at the centered at the
middle of the array).  Because your pulse is shifted in the time
domain, it gets multiplied by a complex phase in the frequency domain
by the shift theorem.

Calling ifftshift on the fft input recenters your data correctly,
giving you a real result for the fft.  However, even with this you
have to be careful, because there is some subtletly in how ifftshift
defines the "center" of the array depending upon whether the length is
even or odd.

Rest assured that Matlab's results are completely correct and
consistent with the standard definition of the DFT.  Whenever it gives
you something different from what you expect, you should be looking
for a flaw in your understanding.

Regards,
Steven G. Johnson