Clear Filters
Clear Filters

I would like to ask how to perform nonlinear fitting with two fixed endpoints. Thank you very much for your answer.

1 view (last 30 days)
The data is shown in the attachment

Accepted Answer

Torsten on 20 Mar 2022
Edited: Torsten on 20 Mar 2022
If your fitting function depends on n parameters to be fitted, the condition that the function passes through 2 fixed points makes you loose 2 free parameters.
If you are not able to solve for 2 of the n parameters by the imposed 2 conditions, use "fmincon" for the fitting and define the two conditions in function "nonlcon".
E.g. if you have a polynomial of degree 3 for fitting
P(x) = a0 + a1*x + a2*x^2 + a3*x^3
and you want
P(x0) = y0, P(x1) = y1,
you have the two additional equations
y0 = a0 + a1*x0 + a2*x0^2 + a3*x0^3
y1 = a0 + a1*x1 + a2*x1^2 + a3*x1^3
Now you could solve for a0 = f0(a2,a3,x0,y0,x1,y1) , a1 = f1(a2,a3,x0,y0,x1,y1) and insert these expressions into the fitting function:
P(x) = f0(a2,a3,x0,y0,x1,y1) + f1(a2,a3,x0,y0,x1,y1)*x + a2*x^2 + a3*x^3
You see: now P only depends on 2 = 4-2 parameters to be fitted, namely a2 and a3.

More Answers (0)


Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!