Assuming that the original signal sample rate is 4000kHz, a set of 1 harmonics consisting of a 200Hz fundamental, which is simulated by the sine function.
Thus get 200hz,400hz,600hz ... 2000Hz, but the magnitude of the 2000Hz here is almost 0, which is explained in detail later.
Time domain waveform with a 200Hz amplitude of 1. FFT transformation, the amplitude of the corresponding frequency is still 1, the frequency is still 200Hz, the mirror frequency symmetry, at the frequency (4000-2000) Hz directly ignored (Nyquist law), this is the Fourier transform is the clever place. 400,600, ... The same is true for 1800Hz.
For 2000Hz, it is strange to have some clutter.
The reason is that the accuracy of pi is a problem, matlab default is 3.1416, so forced pi=3.1415926;
The effect is much better, but the amplitude is not 1, unlike other values, the frequency amplitude is not 1, close to 0,sin (Pi*n), all the time domain value is 0, so the corresponding value of the frequency is close to 0.
Finally get the harmonic graph.
Filter harmonics by using a dressing filter.
Filter the Spectrum after removal
There are always some deviations in actual and theoretical
Filter harmonic removal by comb filter