next up previous contents
Next: Windowing Up: Fourier Transform Previous: Fourier Transform   Contents

Introduction

Fourier Transform can be seen as a tool that converts a signal into a sum of sinusoids of different frequencies, amplitudes and phases. In general, both input and output of the Fourier Transform are complexes and both vectors have the same length. A frequent difficulty in understanding Fourier Transform lies in the comprehension of the physical meaning of the arrays.

The aim of the present chapter is to understand what we get when we apply the command `fft' to an array and how to relate this information with the characteristics of the original signal. We will use sampling rates similar to those used in Clinical Neurophysiology to clarify these aspects.

We are going to sample a sinusoid at 9 Hz of an amplitude of `30'. Amplitude could be volts or any other physical magnitude. We decide to sample the signal at 100 Hz (the period of sampling is 0.01) and we are going to consider 2 seconds of signal. Of course in two seconds there will be 18 cycles.


inct = 0.01;
N = 200;
t = (0:N-1) * inct;

frec = 9;

signal  = 30 * sin (2 * %pi * frec * t + 0.4 * %pi);

plot2d(signal);

Now we are going to plot the Fourier Transform of this array And here is the result without correction of x-axis.

Figure 11.1: Two seconds of the sinusoid at 9 Hz. Notice that x-axis is not expressed in proper units.
\begin{figure}
\epsfbox{figures/fourier1.eps}
\end{figure}

We can correct the x-axis with


xbasc()
plot2d(t,signal);

And the result is

Figure 11.2: Two seconds of sinusoid at 9 Hz. The x-axis is expressed properly in seconds.
\begin{figure}
\epsfbox{figures/fourier2.eps}
\end{figure}

The command to apply Fourier Transform in Scilab is `fft(input,-1)' being `input' the array at which we are going to apply the transform. The result is a vector of the same length that the input. Since the result is a complex array with real and imaginary values, to plot it we have to consider the module of each value. We extract the module of a complex value by using the command `abs'.


ffsignal = fft (signal, -1);

xbasc()
plot2d(abs(ffsignal));

We get the next plot

Figure 11.3: Module of the Fourier Transform. The x-axis is not expressed in Hz
\begin{figure}
\epsfbox{figures/fourier3.eps}
\end{figure}

Here we have arrived to the most difficult step. We have two peaks with only one frequency. What does it mean? First of all, we have to understand the relation between sampling period and frequency.


incf = 1 / (N*inct);
f = (0:N-1) * incf;

The frequency increment is the inverse of the total time considered. If we build a vector of frequencies and plot it with the transform


xbasc()
plot2d(f,abs(ffsignal));

we get

Figure 11.4: Module of the Fourier Transform. Frequencies are expressed in Hz, frequencies above 50 Hz represent negative frequencies from -49 to -1 Hz
\begin{figure}
\epsfbox{figures/fourier4.eps}
\end{figure}

This figure is easier to understand. In x-axis we can see frequencies from 0 to 100 with a peak at 9 Hz. These peaks represent the frequency of the sinusoid at which we applied Fourier Transform. To explain the second peak we have to remember the chapter about sampling.

When we sample a signal we can not get any frequency above Nyquist frequency. Since we sampled the sinusoid at 100 Hz, there can not be frequencies above 50 Hz. As a matter of fact frequencies go from `-50' to `50'. The first 50 values represent frequencies from `0' to `49', the second 50 values represent frequencies from `-50' to `-1'. So the value that we see at a frequency of `91' corresponds to a frequency of `-9'.

Fourier Transform has produced two symmetrical peaks at a frequency of `9' and `-9' Hz. The transform of a sinusoid produces two peaks at negative and positive frequencies (Frequently only frequencies from `0' to `Nyquist frequency' are represented).

Now we have to establish the relation between the amplitude of the signal and the amplitude of the transform. We have an amplitude of about `3000' in each peak. If we divide the transform by the number of samples:


xbasc()
plot2d(f,abs(ffsignal/N));

we get the next plot:

Figure 11.5: Module of the Fourier Transform. Amplitude has been corrected
\begin{figure}
\epsfbox{figures/fourier5.eps}
\end{figure}

We can plot the graph modifying the x-axis to show positive and negative frequencies (remember that frequencies above Nyquist frequency are actually negative frequencies).


-->f(101:200) = f(101:200)-100;
 
-->plot2d(f,abs(ffsignal/N));

Figure 11.6: Module of the Fourier Transform. Negative frequencies are shown
\begin{figure}
\epsfbox{figures/fourier6.eps}
\end{figure}

We have two peaks with an amplitude of 15. If we add both peaks we get and amplitude of `30', the original amplitude of the sinusoid. We would like to stress that we only changed the representation of `ffsignal'. But `ffsignal' contains all the information. The inverse transformation is `fft(ffsignal,1)'. Notice that the parameter `-1' or `1' indicates to Scilab whether the direct Fourier Transform (time to frequency) or the inverse Fourier Transform (frequency to time) has to be done.


-->signal2 = fft(ffsignal,1);
 
-->max(abs(signal-signal2))
 ans  =
 
    1.794E-14

This result clearly shows that there are no significant differences between the original signal (`signal') and the signal that we get after making direct and inverse Fourier Transform of the signal (`signal2'), being the maximum difference about `2E-14'.


next up previous contents
Next: Windowing Up: Fourier Transform Previous: Fourier Transform   Contents
je 2006-10-13