Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!news.glorb.com!postnews.google.com!p25g2000hsf.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 12:33:16 -0800 (PST)
Organization: http://groups.google.com
Lines: 27
Message-ID: <f187d8bb-5e73-491c-94ae-56d64264cfbe@p25g2000hsf.googlegroups.com>
References: <fq9o0h$o6s$1@fred.mathworks.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 1204317196 17125 127.0.0.1 (29 Feb 2008 20:33:16 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 29 Feb 2008 20:33:16 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: p25g2000hsf.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:454672


On 29 Feb, 20:56, "Michael Stachowsky" <mstachow...@gmail.com> wrote:
> I am trying to perform an FFT on some data. =A0My data is:
>
> times =3D [1:1000];
> accelArray =3D 0.7*sin(50*times);
>
> Then I do:
>
> fftAccel =3D (fft(accelArray))/length(accelArray);
> fftFreqs =3D Fs/2*linspace(0,1,length(accelArray)/2);
>
> Then, when plotting, I do this:
>
> plot(fftFreqs,2*abs(fftAccel(1:length(accelArray)/2)));
>
> Now, I'm expecting to get a peak at 50Hz, but instead I get
> a peak at 42.8Hz. =A0I've tried to put sin(2*pi*50*times), but
> that just gives me numbers that are close to 10^-11.

I tried to run your code, but got an error message that Fs is not
specified. You need to specify it and make sure that the vector
times is set up as

Fs =3D <????>
times =3D (0:1000)/Fs;

Rune