Path: news.mathworks.com!not-for-mail
From: "Michael Stachowsky" <mstachowsky@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: FFT acting strangely...
Date: Fri, 29 Feb 2008 20:51:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 49
Message-ID: <fq9r7m$e0j$1@fred.mathworks.com>
References: <fq9o0h$o6s$1@fred.mathworks.com> <f187d8bb-5e73-491c-94ae-56d64264cfbe@p25g2000hsf.googlegroups.com>
Reply-To: "Michael Stachowsky" <mstachowsky@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 1204318262 14355 172.30.248.35 (29 Feb 2008 20:51:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 29 Feb 2008 20:51:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1276742
Xref: news.mathworks.com comp.soft-sys.matlab:454673


Ah, sorry.  Fs = 1000;

I discovered my problem: it was one of aliasing.  I had
mistyped the example data.

But I came upon another issue.  This may stem from my lack
of familiarity with FFT, but, how do I make the proper array
of frequencies for my analysis?

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...

Mike

Rune Allnor <allnor@tele.ntnu.no> wrote in message
<f187d8bb-5e73-491c-94ae-56d64264cfbe@p25g2000hsf.googlegroups.com>...
> 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