Fit function versus lsqcurvefit
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
this hopefully will be a quick question/answer. I am curious as to the difference between the "fit" function and the "lsqcurvefit" function. I ask this because for "fit" you can specify any model using an anonymous function (among other methods). For example, if I have a function that involves a convolution with some parameters in it that need to be fit, can I use the "fit" function or do I have to use the lsqcurvefit?
Appreciate the response.
0 comentarios
Respuestas (1)
dpb
el 21 de Oct. de 2015
It's your choice; fit is a wrapper around a whole bunch of stuff to try to make a general interface for the Curve Fitting Toolbox whereas lsqcurvefit can be thought of as a "lower-level" function for direct access that's in the Optimization Toolbox. Another case where there's duplicated abilities with an initially somewhat different target audience that ends up in questions like this of "why?"...and, of course, there's no direction from TMW as to where one would choose one or t'other if do have both.
4 comentarios
VIGNESH BALAJI
el 4 de Ag. de 2023
@dpb does that mean both fir and lsqcurvefit use the same optimisation algorithm ?
I see that fit uses a trust region algorithm (like a damped least squares) and lsqcurvefit (uses a non linear least squares algorithm). I am not sure whether they both have the same method. Can you comment on this ?
dpb
el 4 de Ag. de 2023
Editada: dpb
el 4 de Ag. de 2023
Internals may/probably do vary slightly as the are of quite different ages of introduction and, like so much recently introduced toolboxes, have duplications of functionality with differences in inputs/outputs.
Both include by user input a Trust Region as well as a Marquardt-Levenberg option for nonlinear, while lsqcurvefit also can use the 'interiorpoint' method from fmincon with some modifications regarding how it computes the Hessian.
So, they use the same general schemes either by default or user selection with some internal variations and also some additional user choices available (or not) depending upon which you choose.
There is no clear-cut definition of precisely what any of them do; the best one can do is read through all the supporting "Algorithms" section information there is and all the links from those to get a general idea, but it isn't a complete description of all the ins and outs -- and the more recent toolboxes have much less in their doc than does the original release doc.
Add to that, that there are the base routines plus the Curve Fitting and Optimization and the Statistics Toolboxes plus a number of others that have very similar but slightly different functionalities, the possiblities are almost innumerable.
As I've complained before, that TMW seemingly doesn't have any overall master plan for the product but just keeps releasing more and more toolboxes with all these overlapping functionalities leaves the user at a loss as to which to choose for a given purpose and why...all the doc there is is written almost totally without reference to other tools. That's reasonable from the standpoint that one TB can't assume that the user will have another one, but it then leads to there being no overall guide.
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!