Adding a condition to the non-linear least square curve fitting

Hello everyone,
I have a question regarding curve fitting using nonlinear regression.
My aim is to calculate three model parameters (a,b,c) out of measurement data to create a physical model. It is a polynomial model with the equation: y=a*x^2+b*x+c
To ensure the physical meaningfulness, the parameters must furthermore fulfill the condition: a+b+c=1
My present code is:
options = fitoptions('Method', 'LinearLeastSquares')
[f_p_zip,g_p_zip]=fit(v_pu,p_pu,'poly2',options);
Unfortunately I cannot find a way to add the condition into the regression process.
Have you an idea how to solve this problem?
Thank you very much in advance,
Kind regards,
Steffi

2 Comments

Hi, take "c=1-a-b" into your fitting function, the your function will be become as: y=a*x^2+b*x+1-a-b, in such case, you don't need to consider any other condition.
Thank you Alex.
This is a very good and elegant way to solve the problem!
Best regards, Steffi

Sign in to comment.

Answers (0)

Categories

Products

Release

R2021a

Asked:

on 9 Jun 2021

Commented:

on 10 Jun 2021

Community Treasure Hunt

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

Start Hunting!