Thread Subject: fft for beginners

Subject: fft for beginners

From: JMMO MartinOlalla

Date: 4 Jul, 2009 06:44:02

Message: 1 of 5

Hi all,

I am just starting doing fft with MatLab. No previous experience.

I am working with 2^19 experimental data points extending over some 50hours arranged as a vector X whose length is 2^19. I am getting on the fft since I need to study correlations and convutions in sets of different experimental data (so ifft will be also needed)

Since the rate of time in the experimental data is known I can control easily what the index of X means: say, from X(1,i) to X(1,i+1) there are 0.11ms while, of course, the first datapoint is t=0.

Now, I got: W=fft(X), which is again a vector whose length is 2^19.

My question is how is the index of this vector W running in the frequency domain? Say, low index means low frequency? frequencies are equally spaced? on what basis?

Also, I would like to know what would I be doing if I fftshift the vector W.

Thanks in advance.

Subject: fft for beginners

From: Luca Zanotti Fragonara

Date: 4 Jul, 2009 15:33:01

Message: 2 of 5

Low indexes means low frequencies?

Yes, but remember that the second half of W contains negative frequencies (which usually are useless, but depends from your field of applications).

Frequency are equally spaced?

Yes.

On what basis?

It depends from your sampling time. If you didn't choose the nfft option, the fft command uses the default option, which calculates a fft which has length equal the length of X (your array).
So in order to build your frequency axis, you will have to use:
f = Fs/2*linspace(0,1,NFFT/2+1);

Where Fs is your sampling frequency and NFFT is the length of your fft.

Greetings,

Luca


"JMMO MartinOlalla" <none@us.es> wrote in message <h2mtni$phl$1@fred.mathworks.com>...
> Hi all,
>
> I am just starting doing fft with MatLab. No previous experience.
>
> I am working with 2^19 experimental data points extending over some 50hours arranged as a vector X whose length is 2^19. I am getting on the fft since I need to study correlations and convutions in sets of different experimental data (so ifft will be also needed)
>
> Since the rate of time in the experimental data is known I can control easily what the index of X means: say, from X(1,i) to X(1,i+1) there are 0.11ms while, of course, the first datapoint is t=0.
>
> Now, I got: W=fft(X), which is again a vector whose length is 2^19.
>
> My question is how is the index of this vector W running in the frequency domain? Say, low index means low frequency? frequencies are equally spaced? on what basis?
>
> Also, I would like to know what would I be doing if I fftshift the vector W.
>
> Thanks in advance.

Subject: fft for beginners

From: Greg

Date: 4 Jul, 2009 18:43:05

Message: 3 of 5

On Jul 4, 2:44 am, "JMMO MartinOlalla" <n...@us.es> wrote:
> Hi all,
>
> I am just starting doingfftwith MatLab. No previous experience.
>
> I am working with 2^19 experimental data points extending over some 50hours arranged as a vector X whose length is 2^19. I am getting on thefftsince I need to study correlations and convutions in sets of different experimental data (so ifft will be also needed)

N = 2^19 % 524288
tmax = 50*60*60 % 180000
dt = tmax/(N-1) % 0.3433

t = dt*(0:N-1);
T = N*dt
t = 0:dt:T-dt;

Fs = 1/dt
df = 1/T
Fs = N*df
f = df*(0:N-1);
f = 0:df:Fs-df;

> Since the rate of time in the experimental data is known I can control easily what the index of X means: say, from X(1,i) to X(1,i+1) there are 0.11ms while, of course, the first datapoint is t=0.

You lied. If

dt = 1.1e-4

% then

tmaxsec = (N-1)*dt % 57.6716 seconds

tmaxhr = tmaxsec/3600 % 0.0160 hours (NOT ~ 50)

did you mean tmax ~ 50 sec ???

Anyway, go back and recalculate all of the above quantities

> Now, I got: W=fft(X), which is again a vector whose length is 2^19.
>
> My question is how is the index of this vector W running in the frequency domain? Say, low index means low frequency? frequencies are equally spaced? on what basis?

See above formula for f

> Also, I would like to know what would I be doing if I fftshift the vector W.

Then the N index periodicity is used to shift all frequences
at the Nyquist frequency Fs/2 = N*df/2 and above to negative
frequencies

fb = df*(-N/2:N/2-1);

Hope this helps.

Greg

Subject: fft for beginners

From: Greg

Date: 4 Jul, 2009 18:57:23

Message: 4 of 5

PLEASE DO NOT TOPPOST!

On Jul 4, 11:33 am, "Luca Zanotti Fragonara" <Luca_Zano...@libero.it>
wrote:
> Low indexes means low frequencies?
>
> Yes, but remember that the second half of W contains negative frequencies (which usually are useless, but depends from your field of applications).

In particular, if X is real, the frequency components
above the Nyquist freqency are redundant because of
conjugate symmetry about the Nyquist frequency.

Hope this helps.

Greg

Subject: fft for beginners

From: Etaoin

Date: 6 Jul, 2009 08:53:01

Message: 5 of 5

Thank you very much to Greg and and Luca; much more clear now.

Yes, I 'lied', it was not 0.11ms. Actually it was 0.11111111111mh=4s.


Greg <heath@alumni.brown.edu> wrote in message <b03e0cd2-9bba-477e-b2d0-37431867c269@j32g2000yqh.googlegroups.com>...
> On Jul 4, 2:44?am, "JMMO MartinOlalla" <n...@us.es> wrote:
> > Hi all,
> >
> > I am just starting doingfftwith MatLab. No previous experience.
> >
> > I am working with 2^19 experimental data points extending over some 50hours arranged as a vector X whose length is 2^19. I am getting on thefftsince I need to study correlations and convutions in sets of different experimental data (so ifft will be also needed)
>
> N = 2^19 % 524288
> tmax = 50*60*60 % 180000
> dt = tmax/(N-1) % 0.3433
>
> t = dt*(0:N-1);
> T = N*dt
> t = 0:dt:T-dt;
>
> Fs = 1/dt
> df = 1/T
> Fs = N*df
> f = df*(0:N-1);
> f = 0:df:Fs-df;
>
> > Since the rate of time in the experimental data is known I can control easily what the index of X means: say, from X(1,i) to X(1,i+1) there are 0.11ms while, of course, the first datapoint is t=0.
>
> You lied. If
>
> dt = 1.1e-4
>
> % then
>
> tmaxsec = (N-1)*dt % 57.6716 seconds
>
> tmaxhr = tmaxsec/3600 % 0.0160 hours (NOT ~ 50)
>
> did you mean tmax ~ 50 sec ???
>
> Anyway, go back and recalculate all of the above quantities
>
> > Now, I got: W=fft(X), which is again a vector whose length is 2^19.
> >
> > My question is how is the index of this vector W running in the frequency domain? Say, low index means low frequency? frequencies are equally spaced? on what basis?
>
> See above formula for f
>
> > Also, I would like to know what would I be doing if I fftshift the vector W.
>
> Then the N index periodicity is used to shift all frequences
> at the Nyquist frequency Fs/2 = N*df/2 and above to negative
> frequencies
>
> fb = df*(-N/2:N/2-1);
>
> Hope this helps.
>
> Greg

Tags for this Thread

Everyone's Tags:

fft(3)

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
fft Lei Tang 17 Aug, 2009 20:27:28
fft Luca Zanotti Fragonara 4 Jul, 2009 11:34:05
fft Etaoin 4 Jul, 2009 02:49:04
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com