Global curve fitting for polynomial function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
I have two sets of data (xdata1, ydata1, and xdata2, ydata2) and I would like to do a global curve fit for these. The function is:
y = y0 + ax + bx^2 + cx^3
where y0 is a shared parameter and a, b, and c can vary for each data set.
I am quite new to MATLAB so I am wondering if anyone have a clue of how to do this?
Thank you in advance for any answers.
/Christian
0 commentaires
Réponses (3)
Torsten
le 10 Oct 2016
The objective function for your problem is given by
f(y0,a1,b1,c1,a2,b2,c2)=
sum_{i=1}^{n1}(ydata1_{i}-(y0+a1*xdata1_{i}+b1*xdata1_{i}^2+c1*xdata1_{i}^3))^2 +
sum_{i=1}^{n2}(ydata2_{i}-(y0+a2*xdata2_{i}+b2*xdata2_{i}^2+c2*xdata2_{i}^3))^2
Now take partial derivatives of f with respect to y0,a1,b1,c1,a2,b2,c2.
You'll arrive at a (7x7) linear system of equations in the unknows y0,a1,b1,c1,a2,b2,c2. This can be solved using \ (backslash).
Best wishes
Torsten.
2 commentaires
Torsten
le 11 Oct 2016
Modifié(e) : Torsten
le 11 Oct 2016
Alternativly, solve the (overdetermined) linear system of equations using \ (backslash):
y0+a1*xdata1_{i}+b1*xdata1_{i}^2+c1*xdata1_{i}^3=ydata1_{i} (i=1,...,n1)
y0+a2*xdata2_{i}+b2*xdata2_{i}^2+c2*xdata2_{i}^3=ydata2_{i} (i=1,...,n2)
These are (n1+n2) equations in the unknowns y0,a1,a2,a3,b1,b2,b3.
Best wishes
Torsten.
Voir également
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox 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!