The FFT is an algorithm designed to take the Fourier Transform of a cosine function for example, but also an imported .wav file. We will get to that later on though. The Matlab command is fft(X,N), where X is the function to be transformed over N points. To take the FFT of a cosine function we will need to create t from for example from 1 to 128.
t=1:1:128;
freq=-64:1:63;
f = fft(cos(50*t),128);
figure(1);
plot(freq,abs(f)); note: abs is the absolute
value to remove imaginary X and Y values, leaving the magnitude
title(‘Magnitude of FFT’);
ylabel(‘Amplitude’);
xlabel(‘Frequency
in Hz’);
This plot shows that there are two frequencies contained in a cosine wave, one the negative of the other. The Fourier Transform is based upon Fourier Series which is a way to approximate a signal by creating it out of sines and cosines, or exponentials.
Return to Matlab Tutorial.