필터 지우기
필터 지우기

Fit multivariable objective function using fminsearch

조회 수: 6 (최근 30일)
JayD
JayD 2015년 10월 15일
댓글: Star Strider 2015년 10월 15일
I have been trying to fit bi-exponential function with 4 variables using fminsearch. I am having difficulty to formulate it in correct way. can you please help me to work it out. (The code is successfully run for lsqnonlin but results are very unreasonable)
b=[50 400 800]; ydata=[850 400 90];
f=@(x,b) x(1)*(x(2)*exp(-x(3)*b)+(1-x(2))*exp(-x(4)*b));
x0=[950,0.3,0.002,0.01];
options = optimset('MaxFunEvals',1e9,'MaxIter',1e9,'TolFun', 1e-8, 'TolX', 1e-8);
X=fminsearch(f,x0,options);

채택된 답변

Star Strider
Star Strider 2015년 10월 15일
You cannot do what you want. You have three data pairs, so you can fit a maximum of three parameters, not the four you want to fit. (Consider fitting a line that requires two parameters — slope and intercept — through a point — one data pair. You can fit an infinite number of lines, all of which are ‘correct’.) You do not know what your data are except where you measure them, so interpolating to create more ‘data’ is not an acceptable solution. So regardless of the solver you use, you are not going to get reliable parameter estimates.
You are also missing a cost function in your code. You need to minimise this instead of ‘f’:
SSECF = @(x) sum((f(x,b)-ydata).^2); % Sum-Squared-Error Cost Function
X=fminsearch(SSECF,x0,options);
You still will not get reliable parameter estimates, but at least the code will be correct!
  댓글 수: 2
JayD
JayD 2015년 10월 15일
Thank so much for the response. First of all I apologize putting up my original objective function here. Since I cannot change the data set I have, I made a different approach to merge 2 variable into one and solve it using lsqnonlin and then solve for merged variable in other means.(still lsqnonlin wasn't reliable). Now I can see what I missed for fminsearch was the cost function. This is helpful. Thank you again.
Star Strider
Star Strider 2015년 10월 15일
My pleasure.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by