# function sersicfit

Fit a one-dimensional sersic function to a vector. The sersic function is defined as y(x) = c + Ie * exp(-bn * (x/Re)^(1/n) - 1), with bn = 1.9992 * n - 0.3271.
**Syntax**

*result* = sersicfit(X, Y, errors, estimates [, chisq])
**Arguments**

X: | A vector containing the x values to be fit |

Y: | A vector containing the y values to be fit |

errors: | The errors in Y |

estimate: | Initial estimate for the fit of the form [c, Ie, Re, n]. If n is provided with a negative sign, it won't be fitted and assumed as fixed (with positive sign, of course). |

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 [c, Ie, Re, n] or [c, Ie, Re] if n was kept fixed. When the negative reciprocal value in q is returned, then the angle is also increased by 90 degrees.