Functions > Transforms and Filters > Example: Introduction to FFTs
  
Example: Introduction to FFTs
Fast Fourier transform (FFT) is a numerical method for expressing the frequency content of a set of data measured over time. The data are often continuous, constituting a waveform. To work with the data numerically, they are sampled at regular time intervals at some sample rate. The figures below illustrate some sampled waveforms and the magnitudes of their Fourier transforms plotted against frequency.
Sampled Sine Waveform
1. Use the sin function to define a sinusoidal waveform.
Click to copy this expression
Click to copy this expression
2. Set the number of data points.
Click to copy this expression
Click to copy this expression
3. Set the distance between samples.
Click to copy this expression
Click to copy this expression
4. Set the sample rate.
Click to copy this expression
Click to copy this expression
5. Plot the sinusoidal function.
Click to copy this expression
6. Use the dft function to calculate the Discrete Fourier transform.
Click to copy this expression
X1 is a vector of real and complex numbers.
7. Find the frequencies at which the peak magnitudes occur.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
8. Plot the transformed signal and use markers to show the frequency and magnitude of the peaks.
Click to copy this expression
Sampled Cosine Waveform
1. Use the cos function to define a cosine waveform.
Click to copy this expression
2. Plot the cosine function.
Click to copy this expression
3. Use the dft function to calculate the Discrete Fourier transforms.
Click to copy this expression
X2 is a vector of real and complex numbers.
4. Find the frequencies at which the maximum magnitudes occur.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
5. Plot the transformed signal and use markers to show the frequency and magnitude of the peaks.
Click to copy this expression
Sampled Exponential Waveform
1. Use the exp function to define an exponential waveform.
Click to copy this expression
Click to copy this expression
The vectorization operator is used to get the element-wise values of the function because the determinant operator within the definition returns a single scalar value.
2. Plot the exponential function.
Click to copy this expression
3. Use the dft function to calculate the Discrete Fourier transform.
Click to copy this expression
X3 is a vector of real and complex numbers.
4. Find the frequencies at which the maximum magnitudes occur.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
5. Plot the transformed signal and use markers to show the frequency and magnitude of the peaks.
Click to copy this expression
Sampled Step Waveform
1. Use the if function to define a step waveform.
Click to copy this expression
2. Calculate the impulse magnitude at each interval.
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. Plot the step function.
Click to copy this expression
The magnitude is uniform and equals to 1.2 between 7 and 25.
4. Use the dft function to calculate the Discrete Fourier transform.
Click to copy this expression
X4 is a vector of real and complex numbers.
5. Find the frequencies at which the maximum magnitudes occur.
Click to copy this expression
Click to copy this expression
Click to copy this expression
6. Plot the transformed signal and use markers to show the frequency and magnitude of the peaks.
Click to copy this expression
The maximum magnitude occurs at freq0.