Curve fitting using custom model

4 vues (au cours des 30 derniers jours)
Kyle Wang
Kyle Wang le 28 Juil 2015
Commenté : Elias le 28 Juil 2015
Given set of x and y, how can I solve the parameter a, b and c in the model
y = a * x^b + c
to best fit the given data?
As I will further implement the algorithm in C++, I would prefer not using built-in Matlab functions to solve parameters.
Could anyone please suggest an algorithm? Many thanks, Kyle.
  2 commentaires
Walter Roberson
Walter Roberson le 28 Juil 2015
Are a and x certain to be non-negative ?
Kyle Wang
Kyle Wang le 28 Juil 2015
the given data set x_given and y_given are vectors of positive double numbers. a, b and c could be negative or positive.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 28 Juil 2015
G = @(abc) sum((abc(1)*x0.^abc(2)+abc(3)-y0).^2);
ABC = fminsearch(G, [rand,rand,rand], 'MaxIters', 10000)
the result will not necessarily be exactly correct, and you can pass ABC back in instead of [rand,rand,rand], but I did find that with my test sometimes it cycled near the answer.
fminsearch is a gradient descent method.

Plus de réponses (1)

Torsten
Torsten le 28 Juil 2015
  1 commentaire
Elias
Elias le 28 Juil 2015
sounds interesting thanks

Connectez-vous pour commenter.

Catégories

En savoir plus sur Linear and Nonlinear Regression 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!

Translated by