필터 지우기
필터 지우기

How to use fminsearch to find the unknown variables of equation

조회 수: 3 (최근 30일)
Mahome
Mahome 2017년 7월 22일
댓글: Matt J 2017년 7월 22일
I'm not pretty sure how to use fminsearch with matrix variables. For example if I have
x = [0,1,2,3,4]
y = [5,10,25,40,90]
and question ask, use fminsearch to estimate C1 and C2 of equation y=C1*exp(C2*x). Is possible to find the unknown variables by using fminsearch?
Thank you a lot

채택된 답변

Walter Roberson
Walter Roberson 2017년 7월 22일
It is easiest to do this by starting with the symbolic toolbox.
C = sym('C', [1 2]);
Then
residue = sum( (C(1)*exp(C(2)*x) - y).^2 );
fun = matlabFunction(residue, 'vars', {C});
Now you can fminsearch using fun as the objective function.
The more direct method without searching is
temp = [ones(length(x),1), x.'] \ log(y.');
C1 = exp(temp(1));
C2 = temp(2);
  댓글 수: 1
Matt J
Matt J 2017년 7월 22일
The more direct method without searching is...
This is a good way to initialize fminsearch, but if y has appreciable additive noise, you probably still want to use it to solve the untransformed problem.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by