How to choose solver, optimization or curve fitting?

조회 수: 6 (최근 30일)
Dawn
Dawn 2014년 8월 2일
편집: Matt J 2014년 8월 4일
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
Dawn
Dawn 2014년 8월 2일
Sorry, I was mistaken about mldivide.
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