Making an FFT on MATLAB

Matlab's FFT function takes only one vector, so no frequency info is included. The FFT is based on element-to-element changes in data.

After the FFT function is performed, a separate vector must be created which becomes the frequency values. Here's how:

P = abs(fft(X));
f = D*(0:L/2)/L;

P is the vector containing the fourier-transformed data, X is the original data.
f is the vector with frequency values. D is the interval between successive t-values in the original X data. L is the length of the P vector (i.e. number of values). f now has half the number of elements as P, so when plotting, use:

loglog(f,P(0:L/2),'-')

The rest of the data in P is just the negative-frequency values. It should be noted that these instructions apply only to situations where a power-spectrum is needed (that's why I used the abs function when creating P).