Global curve fitting for polynomial function
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
Torsten
2016-10-10
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 个评论
Torsten
2016-10-11
编辑:Torsten
2016-10-11
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!