From: Chris Goldenstein on
Hi,

I am in the process of developing a code to fit experimental spectroscopic absorption profiles to Voigt profiles. In english, I'm looking to fit a data set to multiple voigt profiles that are overlapping.

I have used fminsearch and nlinfit to fit my data set and the nlinfit is much faster and better a converging for instances where I have several Voigt profiles I need to fit to, and hence, many (9-12) free parameters. I believe this is an attribute of nlinfit using the Levenberg-Marquardt algorithm.

My question is, I just found out about lsqcurvefit and I am wondering how to choose which fitting function is best for me. Can someone explain to me what the strengths and weaknesses are of: fminsearch, nlinfit, and lsqcurvefit and when each should be used? Thanks.
From: John D'Errico on
"Chris Goldenstein" <csgoldenstein(a)gmail.com> wrote in message <hu69ju$oqr$1(a)fred.mathworks.com>...
> Hi,
>
> I am in the process of developing a code to fit experimental spectroscopic absorption profiles to Voigt profiles. In english, I'm looking to fit a data set to multiple voigt profiles that are overlapping.
>
> I have used fminsearch and nlinfit to fit my data set and the nlinfit is much faster and better a converging for instances where I have several Voigt profiles I need to fit to, and hence, many (9-12) free parameters. I believe this is an attribute of nlinfit using the Levenberg-Marquardt algorithm.
>
> My question is, I just found out about lsqcurvefit and I am wondering how to choose which fitting function is best for me. Can someone explain to me what the strengths and weaknesses are of: fminsearch, nlinfit, and lsqcurvefit and when each should be used? Thanks.

If you have the optimization toolbox, use lsqcurvefit or
lsqnonlin.

If you have the statistics toolbox, use nlinfit.

If you have neither toolbox, use fminsearch. However,
fminsearch is not terribly fast nor is it accurate, so it is
never really the tool of choice.

If you have both the stats and optim TBs, then take your
pick of those two tools. You might prefer nlinfit if you
wish to compute parameter uncertainties.

John