Fitting a nonlinear model: Which is the best function?

26 views (last 30 days)
I have to fit more than a thousand vectors of data to biexponential curves, one curve fitting per vector. I was using de function "fit" to this purpose, but it was taking too long. I have tried to look for different ways to do the curve fitting and I have found some useful functions, and I would like to know which are the differences between them, because all of them seem similar to me. Which function is faster? The functions are:
fitnlm
nlinfit
lsqnonlin
lsqcurvefit
Thanks in advance

Accepted Answer

Star Strider
Star Strider on 22 May 2014
The choice is between nlinfit and lsqcurvefit, depending on what you want to do. The Statistics Toolbox nlinfit provides myriad statistics if you want them, but will only fit vector dependent variables. The Optimization Toolbox lsqcurvefit can fit matrix dependent variables, but doesn’t have all the statistics options. (Both can take matrix independent variables, but that requires you deceive the fitting function into believing it has a vector independent variable in your objective function programming. That’s not difficult. The fitting functions are credulous.)
So, if you’re fitting vector dependent variables, go for nlinfit. If you’re fitting matrix dependent variables, go for lsqcurvefit.
My opinion. Others may differ.
  1 Comment
HIGASHI mitsuya
HIGASHI mitsuya on 14 Sep 2020
Hello Star Strider,
I have a question about The Statistics Toolbox fitnlm.
Can fitnlm fit matrix dependent variables ?
I will be really thankgul if you give some information.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!