Derivative constraint in curve fitting
이전 댓글 표시
I have a set of data points in 2D that I want to use fit(x,y,'modeltype') function to test the curve fit of different types of functions. I have tried Fourier series, polynomial, two-term exponential and two-term power functions (one on the increasing and one on the decresing interval). I have two constraints that I want to implement but I dont know how. It is the value and the first derivative in one point. I want the following to hold (the data points are somewhat like an U upside down):
f(1)=1, df/dx(1)=0
How do I implement these connstraints? For these to hold (or be as close to 1 and 0 as possible) is more important than the curve to match all the other data points.
Thank you in advance!
댓글 수: 2
darova
2019년 10월 31일
You can add two points at the beginning. Derivative means df/dx = tan(a) (tangens of an angle)

Ane Følgesvold Reines
2019년 10월 31일
답변 (2개)
Matt J
2019년 10월 31일
1 개 추천
You can do spline fits with those kinds of constraints using this,
댓글 수: 3
Ane Følgesvold Reines
2019년 10월 31일
Matt J
2019년 10월 31일
A spline of order 2 or higher will have continuous first derivatives and the SLM toolbox provides tools for evaluating them.
Ane Følgesvold Reines
2019년 11월 1일
Cyrus Tirband
2019년 10월 31일
0 개 추천
If you absolutely have to make sure your constraints are met, you have to change your fitting equation so that all possible solutions satisfy your constraints. Consider the 2nd degree polynomial:
if the constraints are y'(1) = 0, and y(1) = 1; we get
Your fitting equation then becomes
Which will give shitty results since it only has one degree of freedom. But this is just an example, if you start with a 4th degree polynomial, your fitting equation will have three degrees of freedom. The fit function will then take care of the rest and minimize the least squares cost.
댓글 수: 2
Ane Følgesvold Reines
2019년 10월 31일
Cyrus Tirband
2019년 10월 31일
Matlab does not have this functionality.
카테고리
도움말 센터 및 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!