Functions > Data Analysis > Curve Fitting > Example: Sinusoidal Regression
  
Example: Sinusoidal Regression
Use the sinfit function to perform a sinusoidal regression. This is particularly appropriate if your data oscillates with a regular period.
1. Define a data set.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
2. Define a vector of guesses.
Click to copy this expression
In some cases, you must adjust the guesses to get the best possible fit. The first value should be approximately equal to the amplitude of your data, the second should be equal to the phase shift, and the third should be equal to the offset.
3. Call the sinfit function to find the parameters of the sinusoidal fit.
Click to copy this expression
Click to copy this expression
The parameters are those found in the following sinusoidal equation:
Click to copy this expression
4. Plot the data and the sinusoidal fit.
Click to copy this expression
Click to copy this expression
Click to copy this expression
The fit is almost perfect, as confirmed by the correlation coefficient:
Click to copy this expression