I generated a sample signal using sum of three sine waves. When I plot the signal using fft command to view the individual frequency components, I always get an error in the second (i.e., second in ascending order) frequency component. It either shows up as half the correct frequency or some multiple (twice/ four times, etc). If the frequency is correct, the amplitude is incorrect. The other two frequencies and amplitudes are always correct.
I tried adding a fourth signal, but the same problem repeats with the second signal only. All others are correct. I tried with two signals only and the result is the same. Second signal is wrong.
Tried restarting Matlab, but it repeats. I tried different values of frequencies and amplitudes, but it is always the second in ascending order which misbehaves. Did not try more than 4 frequencies. I am totally flabbergasted! I am not very familiar with fft, Am trying to learn. Attaching the code and output figure. Any help would be welcome please.
f_max=max([f1 f2 f3 f4]);
x = A1*cos(2*pi*f1*t)+1*cos(A2*pi*f2*t)+A3*cos(2*pi*f3*t)+A4*cos(2*pi*f4*t);