Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!i29g2000prf.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: FFT acting strangely...
Date: Fri, 29 Feb 2008 13:16:04 -0800 (PST)
Organization: http://groups.google.com
Lines: 35
Message-ID: <c44bb38e-3c5a-41e0-b638-9ae21acbcb77@i29g2000prf.googlegroups.com>
References: <fq9o0h$o6s$1@fred.mathworks.com> <f187d8bb-5e73-491c-94ae-56d64264cfbe@p25g2000hsf.googlegroups.com> 
NNTP-Posting-Host: 212.17.141.53
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1204319764 25054 127.0.0.1 (29 Feb 2008 21:16:04 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 29 Feb 2008 21:16:04 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: i29g2000prf.googlegroups.com; posting-host=212.17.141.53; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET 
Xref: news.mathworks.com comp.soft-sys.matlab:454696


On 29 Feb, 21:51, "Michael Stachowsky" <mstachow...@gmail.com> wrote:
> Ah, sorry. =A0Fs =3D 1000;
>
> I discovered my problem: it was one of aliasing. =A0I had
> mistyped the example data.
>
> But I came upon another issue. =A0This may stem from my lack
> of familiarity with FFT, but, how do I make the proper array
> of frequencies for my analysis?

You don't. The array of frequencies is given implicitly as

fv =3D (0:N-1)/N*Fs

where N is the length of the data sequence fed to the FFT
and Fs is the sampling frequency.

> This is going to be used in an experiment with reasonably
> strict accuracy controls (at least +/- 0.1Hz), and my FFT
> analysis gave me 120.12Hz when I gave it a 120Hz sine wave...

You have to determine a largest acceptable bin width df
and compute the minimum sequence length as

N >=3D Fs/df

For Fs =3D 1000 Hz and df =3D 0.1 Hz one gets

N >=3D 1000/0.1 =3D 10000

mening that you need at least 10000 samples in the
signal vector to guarantee that you end up within
0.1 Hz of the desired signal.

Rune