Thread Subject: Scaling the fft

Subject: Scaling the fft

From: Ben Price

Date: 9 Nov, 2007 12:35:46

Message: 1 of 3

Hi

I am trying to perform an fft on some data but have been
having trouble with the scaling of the frequency axis. I
started testing things with gaussians. If one starts with
a gaussian of full width half maximum of 1.386a then the
resulting gaussian on transform is expected to have width
0.44/a. This is a well known mathematical result.

I defined a number of gaussians of various widths and then
took the fft of each. Each gaussian is defined over 32,768
points (2^15) and thus the fft returned equally has 2^15
points. For example define a gaussian with mean 0,
standard deviation 1 over the range x = (-
16.384:0.001:16.383). When plotting the fft values returned
against the original time axis (x) of the input gaussian
one would expect to find that a common scaling factor is
required to scale the x-axis in order to give the gaussians
the correct widths - indeed it is...21.625

When I repeat this using box functions of various widths
however the scaling factor required changes depending on
the box function and is certainly never equal to 21.625 as
before. For a box function of width 'a' one expects that
the fft is a sinc function with first minima at 1/a.

So why does the scaling factor change in different cases?
This should be the same for ANY 32,768 point function.

Many thanks

Ben

Subject: Scaling the fft

From: Rune Allnor

Date: 9 Nov, 2007 12:55:34

Message: 2 of 3

On 9 Nov, 13:35, "Ben Price" <bpr...@medphys.ucl.ac.uk> wrote:
> Hi
>
> I am trying to perform an fft on some data but have been
> having trouble with the scaling of the frequency axis. I
> started testing things with gaussians. If one starts with
> a gaussian of full width half maximum of 1.386a then the
> resulting gaussian on transform is expected to have width
> 0.44/a. This is a well known mathematical result.

Try sinusoidals instead. They are easier to troubleshoot.

> I defined a number of gaussians of various widths and then
> took the fft of each. Each gaussian is defined over 32,768
> points (2^15) and thus the fft returned equally has 2^15
> points. For example define a gaussian with mean 0,
> standard deviation 1 over the range x = (-
> 16.384:0.001:16.383). When plotting the fft values returned
> against the original time axis (x) of the input gaussian
> one would expect to find that a common scaling factor is
> required to scale the x-axis in order to give the gaussians
> the correct widths - indeed it is...21.625
>
> When I repeat this using box functions of various widths
> however the scaling factor required changes depending on
> the box function and is certainly never equal to 21.625 as
> before. For a box function of width 'a' one expects that
> the fft is a sinc function with first minima at 1/a.

What reference are you comparing against? The Fourier
integral or the DFT? Again, the troubleshooting is
significantly easier with sinusoidals.

> So why does the scaling factor change in different cases?
> This should be the same for ANY 32,768 point function.

I can see two possible causes:

The first is that your refernce is the Fourier integral
of a countinuous-time Gaussian. The second is that the
DFT as implemented by matlab is not unitary, you need to
divide by a factor sqrt(N) to make Parseval's equation
work.

Provided, of course, that I have understodd the test
you did, which by no means is certain.

Try to compute the DFT of a sinusoidal, and reformulate
the question from those results. Troubleshooting becomes
a lot easier.

Rune

Subject: Scaling the fft

From: Randy Poe

Date: 9 Nov, 2007 15:10:19

Message: 3 of 3

On Nov 9, 7:35 am, "Ben Price" <bpr...@medphys.ucl.ac.uk> wrote:
> Hi
>
> I am trying to perform an fft on some data but have been
> having trouble with the scaling of the frequency axis. I
> started testing things with gaussians. If one starts with
> a gaussian of full width half maximum of 1.386a then the
> resulting gaussian on transform is expected to have width
> 0.44/a. This is a well known mathematical result.
>
> I defined a number of gaussians of various widths and then
> took the fft of each. Each gaussian is defined over 32,768
> points (2^15) and thus the fft returned equally has 2^15
> points. For example define a gaussian with mean 0,
> standard deviation 1 over the range x = (-
> 16.384:0.001:16.383). When plotting the fft values returned
> against the original time axis (x) of the input gaussian
> one would expect to find that a common scaling factor is
> required to scale the x-axis in order to give the gaussians
> the correct widths - indeed it is...21.625
>
> When I repeat this using box functions of various widths
> however the scaling factor required changes depending on
> the box function and is certainly never equal to 21.625 as
> before. For a box function of width 'a' one expects that
> the fft is a sinc function with first minima at 1/a.

When I work out the FT for a box function of width
a by hand, I obtain

  F(f) = sin(2*pi*a*f)/pi*f

This function is zero at f = 1/a, which is just what I
see when I calculate an FFT in the way you are
describing.

I'm not sure where your value of 21.625 came from. I'm
using frequency spacing = 1/(total length in seconds
of original time sample).

             - Randy

Tags for this Thread

Everyone's Tags:

fft

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 Ben Price 9 Nov, 2007 07:40:07
rssFeed for this Thread

Contact us at files@mathworks.com