How to choose solver, optimization or curve fitting?

3 次查看(过去 30 天)
Lets say I have 4 known curves in discrete values, S1,S2,S3 and S.
Supposedly S c1*S1 + c2*S2 + c3*S3 and C1+C2+C3 = 1, should I look into using curve fitting toolbox or the optimization toolbox to find the individual values C1, C2 and C3 that will give me a resultant curve that is closest to S?
I am new to this topic and would appreciate pointers to choosing the appropriate algorithm and how to incorporate the constraint C1+C2+C3 = 1 into the curve fit/otimization.
Thanks for any help that I can get.

采纳的回答

Matt J
Matt J 2014-8-2
编辑:Matt J 2014-8-2
Eliminate c3 using c3=1-c1-c2, which reduces the relationship among your curves to,
c1*(S1-S3)+c2*(S2-S3)=(S-S3)
Now just use mldivide to find the least squares solution to the linear equations,
C=[S1(:)-S3(:), S2(:)-S3(:)]\(S(:)-S3(:));
c1=C(1)
c2=C(2);
c3=1-c1-c2;
  4 个评论
Matt J
Matt J 2014-8-4
编辑:Matt J 2014-8-4
Happy that this answer works for you, but be mindful that it will not work if you plan to add bound constraints on c1,c2,c3 as you commented here. Eliminating c3 will convert the bound constraints to more complicated linear inequalities. You would have to use lsqlin as proposed by Ahmet to handle bounds and other linear inequality constraints

请先登录,再进行评论。

更多回答(1 个)

Ahmet Cecen
Ahmet Cecen 2014-8-2
You can either use a regularized regression function, or the optimization toolbox. I would guess optimization is the easier choice. Try lsqlin.
  2 个评论
Matt J
Matt J 2014-8-2
编辑:Matt J 2014-8-2
I would use lsqlin if there are additional inequality constraints like c1>=0, c2>=0, c3>=0. Otherwise, it's way too simple a problem to warrant an iterative solution.
Dawn
Dawn 2014-8-2
Thanks for all your suggestions. I do have some bounds for c1, c2 and c3.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by