Global curve fitting for polynomial function
조회 수: 3 (최근 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!