That is my code, so I will do my best to explain it.
The frequency vector ‘Fv’ here defines the frequencies for a one-sided Fourier transform, going from 0 Hz (d-c) to the Nyquist frequency. The length is determined by half the length of the original signal vector (+1 since it begins at 0). (Since the time vector is always a vector and not a matrix, and the signal could be a matrix, it is easier to use the time vector to determine the length of the signal.) The length of the two-sided Fourier transform (most easily appreciated after using fftshift on it) is the same as the length of the original signal vector (unless the length is increased by zero-padding it, that being a separate discussion).
The index vector ‘Iv’ just makes plotting and other references to the one-sided fft result easier. It is equal to the number of elements in the frequency vector, so the lengths match when plotted or otherwise processed.
With respect to ‘FTS_plot’, I am not certain what this code refers to (with this, I will have posted 13495 Answers, and I do not remember all of them), however it appears that it was intended to plot the normalised fft, so that the highest value is 1 and everything else is between 0 and 1. That is not how I usually plot fft results, so there must have been a specific reason for it.
If you have any further questions about my code here, I will do my best to address them.
Best Answer