I was trying to calculate the Fourier series coefficients for a raw data (random signal).
I succeeded to calculate the FFT of the signal, but I couldn't calculate the Fourier series coefficients. My main idea is to generate a score or a number which represents how many cos and sin waves can generate my signal. For example, if the signal is a sine wave this means it is 100% pure as it can be generated by only one sine signal, if it consists of two sine waves, this means it is not a pure wave, and if it consists 100 sine waves it is really unpure and so on.
So my solution was to calculate the FFT of the signal and then generate another signal using the IFFT (inverse FFT) with smaller number of FFT samples and check the correlation between the original and the generated signal. If it is the same this means that it has a small number of sine waves. I am not sure I am right or wrong... What is the answer?
My code:
x = fft(s); %s is 2000 sample points
y = ifft(x(1:400), 2000);
c = real(corr(s', y'));