- If you are using lsqnonlin or lsqcurvefit, then your objective function should return the vector of function values (I mean fittingdata - realdata in your vocabulary).
- If you are using any other nonlinear optimizer, then your objective function should be the sum of squares of the function values.
When to use cost function or error function for fitting
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have look around different ways to fit. So when do you know you have to use the cost function: sum((realdata-fittingdata).^2) or error = realdata-fittingdata? For example, for lsqnonlin, you would use 'error' to find do the optimization. However, for fminsearch or patternsearch, you would use the 'cost function.'
0 commentaires
Réponse acceptée
Alan Weiss
le 26 Juin 2017
I'm sorry that you don't find the documentation clear on this issue.
For an example comparing these approaches, including efficiency of each solver, see Nonlinear Data-Fitting.
Alan Weiss
MATLAB mathematical toolbox documentation
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Direct Search dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!