Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Confusion over calculating Fourier transforms
Date: Wed, 2 Dec 2009 15:51:03 +0000 (UTC)
Organization: Xoran Technologies
Lines: 13
Message-ID: <hf62d6$k7a$1@fred.mathworks.com>
References: <hf5c3c$1f5$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1259769063 20714 172.30.248.37 (2 Dec 2009 15:51:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 2 Dec 2009 15:51:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:589537

"Mat Hunt" <hunt_mat@hotmail.com> wrote in message <hf5c3c$1f5$1@fred.mathworks.com>...
> Hi,
> 
> I need to calculate the Fouier transform of some rather complicated functions. Naively, I would do the following (to compute the Fourier transform of a Gaussian say):
> 
> >x=-3:0.001:3;
> >y=exp(-x.^2);
> >f=abs(fft(y));
> >plot(f);
> 
> I just set something which is completely wrong, what am I doing wrong here?

You need to do plot(fftshift(f)) to see the Gaussian as a centered peak (it will be very narrow, so you'll need to zoom in). Right now, you're seeing a circulant shift of this peak.