How can I write code for smooth cosine fit for given data and find residual ?
No products are associated with this question.
Any signal is composed of lots of cosines - that's basically what the Fourier transform (spectrum) is. It's the strength (weight) of all the cosines that can go into building up your signal. Maybe just take the Fourier Transform and look for the highest frequency to determine the frequency of cosine that is contributing most to your signal. Once you know the frequency, just construct a signal and subtract it from your original signal, etc.