help-octave
[Top][All Lists]

## Re: Use of the Fast Fourier Transformation

 From: Wonkoo Kim Subject: Re: Use of the Fast Fourier Transformation Date: Mon, 29 Jun 98 14:45:23 -0400

```> Date: Mon, 29 Jun 98 18:28:45 +0200
> Subject: Use of the Fast Fourier Transformation
>
> Hi !
>
> I would like to know how to use the fft function.
>
> Let's take a simple example :
>
> f(t) = A if -To/2<t<To/2
>        0  anywhere else
>
> I can calculate by hand the fourier transformation of this function :
>
> F(nu) = A*To*sin(pi*nu*To)/(pi*nu*To)
>
>
> However, how can I use fft to compute it ! (Setting A and To with
> numerical values of course). I tried to use the fft function but without
> great success I should admit.

You need to sample f(t) at some sampling rate.  For enough frequency
resolution, take samples from enough region of t. (i.e. take enough
time interval to cover the interval [-To/2, To/2].)  You have samples
from positive and negative time parts and also a sample at t=0.
Put samples from the negative time part in the right half of the
sampled sequence.

Try:

x = zeros(256,1);
x(1:9) = 1;            # x(2:9) = samples from t > 0.
# x(1) = sample at t = 0.
x(249:256) = 1;        # samples from t < 0.
y = fft(x);
plot(real(y));

You need to adjust (compute) real plot scale and frequency axis tics,
which are affected by the sampling period in time and the total time
interval for the samples.

//--------------------------------------------------------------------