function sinfit

Fit a sine curve to a set of data points. The function fit is y(x)=A+B*sin(x+phi)

Syntax
result = sinfit(X, Y, errors, estimate [, chisq])

Arguments
X:   A vector containing the x values to be fit
Y:   A vector containing the y values to be fit (in radians)
errors:   The errors in Y
estimate:   Initial estimate for the fit of the form [A,B,phi]
chisq:   If set to a named variable, the variable is overwritten with the chi-squared of the fit.


Returns
The returned vector contains the best-fit parameters in the form [A,B,phi,d_A,d_B,d_phi]