Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: ratio of fft's
Date: Tue, 20 May 2008 18:54:28 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 35
Message-ID: <g0v6p4$m63$1@canopus.cc.umanitoba.ca>
References: <g0v3jp$27s$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1211309668 22723 192.70.172.160 (20 May 2008 18:54:28 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Tue, 20 May 2008 18:54:28 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:469535


In article <g0v3jp$27s$1@fred.mathworks.com>,
Bruce  <italianasa84@gmail.com> wrote:
>A simple divison, on paper, of two fft's proves that the
>ratio of the fourier transform of two sine waves with the
>same frequency gives exp(-j*phi) where phi is the phase
>shift between the two. Therefore if you take
>angle(exp(-j*phi)) you should get phi, which is a constant.
>Why in matlab do you not get a constant?? Where do those
>spikes come from?

>% y2 = shifted sine wave
>y2 =  sin(2*pi*10*t + phi).*hamming(length(t))'; 

When you use sin() to construct a sine wave that you submit to
fft, then due to round-off error in the calculation of the sine,
you will likely end up something that does not fft to a simple impulse
in the frequency domain: you will get a phase distortion that
will result in non-zero values at most points in the fft.
The power of that phase distortion is quite small, but it is present
and will have a noticable effect on your calculation.

If you start by -constructing- an impulse in the frequency domain
and ifft that back to a signal, the difference between the ifft'd
values and the sin() values you calculated will be on the order of
1E-14 to 1E-16. You cannot distinguish the two waveforms
if you plot them on top of each other: the changes are just too small.

The issue becomes quite prominent if you happen to use sind()
instead of sin(); some day, if I ever get in a fresh supply
of Round Tuits, I may investigate that further and possibly even
file a bug report; when I was experimenting with this a couple of
weeks ago, the sind() differences looked too large to be "reasonable".
-- 
  "Tired minds don't plan well. Sleep first, plan later."
                                              -- Walter Reisch