Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!d45g2000hsc.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 13:48:07 -0700 (PDT)
Organization: http://groups.google.com
Lines: 39
Message-ID: <80a6a285-8758-488c-9b98-beed0d03d19e@d45g2000hsc.googlegroups.com>
References: <fvfs3j$bnf$1@fred.mathworks.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 1209761287 8241 127.0.0.1 (2 May 2008 20:48:07 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 2 May 2008 20:48:07 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: d45g2000hsc.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:466346


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