Path: news.mathworks.com!not-for-mail
From: "Chen Sagiv" <chensagivron@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Does Matlab do FFT correctly ?
Date: Fri, 2 May 2008 20:04:03 +0000 (UTC)
Organization: Sagiv Enterprises
Lines: 33
Message-ID: <fvfs3j$bnf$1@fred.mathworks.com>
Reply-To: "Chen Sagiv" <chensagivron@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1209758643 12015 172.30.248.35 (2 May 2008 20:04:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 2 May 2008 20:04:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 805005
Xref: news.mathworks.com comp.soft-sys.matlab:466344


Hi all,

We all know that the DFT of a square pulse is a sinc. 

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); 

% Now let's view its Fourier transform:

figure ; plot(real(fftshift(fft(f))));
figure ; plot(imag(fftshift(fft(f))));

% Hey, the imaginary part is NOT zero
% a remedy: 
figure ; plot(real(fftshift(fft(ifftshift(f)))));
figure ; plot(imag(fftshift(fft(ifftshift(f)))));

So, it seems that Matlab does correct FFT to signals that 
are not centered about 0, but we have to ifftshift them 
first. 

Is that a known "feature" of Matlab ? I will be glad to get 
a clarification ! 

Best,

Chen Sagiv