Borrar filtros
Borrar filtros

Fit multivariable objective function using fminsearch

6 visualizaciones (últimos 30 días)
JayD
JayD el 15 de Oct. de 2015
Comentada: Star Strider el 15 de Oct. de 2015
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);

Respuesta aceptada

Star Strider
Star Strider el 15 de Oct. de 2015
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 comentarios
JayD
JayD el 15 de Oct. de 2015
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Optimization en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by