SINTREND

Purpose:

Fits y(x) = A + Bx + C sin(Dx + E) using the FFT.

Syntax:

SINTREND(series)

(fit, coef) = SINTREND(series)

series

-

A series or array.

Returns:

A series, the fitted sine curve.

 

(fit, coef) = sintrend(series)

returns both the fit and the coefficients as a series.

Example:

W1: 5 + 3 * gsin(1000, .001, 10) + gline(1000, .001, 20, 0)

W2: sintrend(W1);overp(W1, lred)

 

overplots the original data with the calculated sine fit.

Example:

(fit, coef) = sintrend(W1)

 

fit is the same series as in W2

 

coef == {5.2861, 19.4272, 3.0032, 62.8249, 0.0035}

 

Note: since D == coef[4] == 2*pi*F, in this case, F = 62.8249 / (2π) = 9.9989.

Remarks:

SINTREND first calculates and removes the linear trend in the data, fits a sine, then adds in the calculated linear trend. The resulting fit is of the following form:

 

image\sintrend01.gif

 

The frequency and phase terms are in radians.

 

SINTREND uses SINFIT to find the dominant frequency present in the series.

See Also:

FFT

LINFIT

LSINFIT

SINFIT

TREND