Fit points and specify the slope at one of the points

3 次查看(过去 30 天)
Hello,
I have a series of 4 points:
x=[-0.385444 0 0.985035 4.36849];
y=[0.599583870363438 0.103 1.00644809697272 2.02362891855202];
At x=0.985035, I need the slope to be 0.
How do I do this?
I am familiar with the spline function, but it will only let me specify the slope at the begining and end of the curve.
Thank you.

回答(1 个)

Alex Sha
Alex Sha 2021-2-10
Hi, try the function below:
y = p1+p2*x^2-p3*exp(p4*x);
to ensure the slope being 0 in point of "x=0.985035", should add a constraint of "p2*(2*xx)-p3*(exp(p4*xx)*p4)=0", where xx=0.985035. The result will be:
Root of Mean Square Error (RMSE): 0.287966090994206
Sum of Squared Residual: 0.331697878249934
Correlation Coef. (R): 0.913088032059037
R-Square: 0.833729754289445
Constrained Functions: p2*1.97007-p3*(exp(p4*0.985035)*p4)-0 = 1.44750877950628E-11
Parameter Best Estimate
---------- -------------
p1 -0.154217819730129
p2 -0.391394281530186
p3 -0.727826672642068
p4 0.591562409273376

类别

Help CenterFile Exchange 中查找有关 Splines 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by