# LSINFIT

## Purpose:

Performs known frequency sine curve fitting using the least squares method.

## Syntax:

LSINFIT(series, freq, mode)

series

-

A series, the input sinusoid.

freq

-

A real, the known frequency of the input signal.

mode

-

Optional. An integer, the sinusiod form:

 0: Returns the fitted curve and optionally the coefficients and rms error for the equation: If the output is directed to variables: (fit, coef) = lsinfit(series, freq, mode)   mode 0 returns coefficients in the form: coef = {A1, B1, C, RmsError} 1: (Default). Returns the fitted curve and optionally the coefficients and rms error for the equation: If the output is directed to variables: (fit, coef) = lsinfit(series, freq, mode)   mode 1 returns coefficients in the form: coef = {A, theta, C, RmsError}

## Returns:

A series and optionally the coefficients and rms error of the fitted curve.

## Example:

W1: gsin(1000, .001, 4)

W2: lsinfit(w1, 4, 0)

Fits the generated data to the function:

## Example:

W1: gsin(1000, .001, 4)

(fit, coef) = lsinfit(w1, 4, 1)

W2: fit

W3: coef

Fits the generated data to the function:

W2 will contain the fitted curve and W3 will contain the coefficients in the form:

coef = {A, theta, C, rmserror}

## Remarks:

The known frequency approach to sine curve fitting is commonly used in effective bits calculation. The output of the function is dependant on knowing the frequency of the input series.

See SINFIT3 to perform a sinusoid fit with a known or unknown frequency.

SINFIT4 to perform an iterative least squares sinusoid fit.