How to do a discrete Fourier transform (FFT) and to plot the amplitude and phase spectrum in MATLAB
Channel: Mathias Magdowski
Date: 2021-04-24

In this short video, I explain how to load a time function (some simulated signal) and the corresponding (equally spaced) time steps from a text file into MATLAB. After plotting the time function, the discrete Fourier transform is used to convert the signal from time domain into frequency domain an to calculate the spectral components of the signal's frequency spectrum as well as the corresponding positive frequencies. The complex spectrum is then plotted by magnitude (or amplitude) and phase using a stem plot. For the Fourier transform, a special function called fourier.m is used, which is based on the fft function that is built into MATLAB. Another function called invfourier.m, which is based on the ifft function built into MATLAB, would do the inverse Fourier transform from the frequency domain back into time domain.

Example as an Octave Online Bucket:
https://octave-online.net/bucket~CQ8X9mXpy9NaZdF4rSsLQX

Chapter marks:
0:00 Introduction
1:04 Load the data
2:07 Discussion of the fft function
3:55 Plot the time function
4:40 Calculate the spectrum
7:16 Plot the amplitude spectrum
10:22 Plot the phase spectrum