I have some data that I've noticed conforms to a sine wave. Details of the data is unknown. My task is to approximate it as closely as possible.

From some experimentation in Excel, I noticed the data follows a sine wave, so attempted to plot in the base sine wave (orange) and am now trying to approximate the blue line. I believe this is a simple job of harmonics being added to the base sine wave, however; the quantity and their respective amplitude and harmonic number (2nd harmonic being 2 * f, 3rd harmonic being 3 * f etc) is what I now need to calculate. I'm also guessing the amplitude of the resulting wave is modified by possibly a sine wave too.

Is there software which could automate this and approximate it through some analysis (Fourier analysis maybe) or possibly brute force, or is it something I have to write myself?

enter image description here


1 Answer 1


You want to look at the spectral density to get an idea of the distribution of the frequency components. Check out the 'psd' package in r or the signal processing toolbox if you have access to Matlab.

  • $\begingroup$ Interesting, I don't have access to Matlab, but is it possible to do it in octave? $\endgroup$ Mar 24, 2016 at 1:16
  • $\begingroup$ I have not used it, but there does seem to be a signaling package: octave.sourceforge.net/signal $\endgroup$
    – dmb
    Mar 24, 2016 at 1:18
  • $\begingroup$ Thanks! As I've achieved a mini-victory spotting this sine wave after modifying the input data, I'll reward myself and go to bed now! I'll experiment with Octave in the morning! $\endgroup$ Mar 24, 2016 at 1:23
  • $\begingroup$ Am I right in assuming that peaks in the positve mean the signal has that particular frequency and negative troughs mean the frequency is present, but out of phase? How exactly do I determine the precise phases of the sines? $\endgroup$ Mar 24, 2016 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.