Fitting an exponential using nlinfit
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Matthew
el 13 de Nov. de 2015
Comentada: Star Strider
el 17 de Nov. de 2015
I am trying to fit an exponential fit to some data... I have tried using Nlinfit but don't seem to be getting anywhere
nlmodel=@(b,time_bbdom)b(1)+b(2)*exp(-b(3)*time_bbdom(:,1));
beta0=[0;1;0.1];
mdl=nlinfit(time_bbdom,lum_bbdom,nlmodel,beta0);
I think the problem is my starting conditions beta0... How do I choose these variables? the error i get is Error using nlinfit>checkFunVals (line 612) The function you provided as the MODELFUN input has returned Inf or NaN values.
Error in nlinfit>LMfit (line 559) if funValCheck && ~isfinite(sse), checkFunVals(r); end
Error in nlinfit (line 276) [beta,J,~,cause,fullr] = LMfit(X,yw, modelw,beta,options,verbose,maxiter); Can anyone point me in the right direction? I would have thought its quite easy but i am not finding the documentation particularly helpful....
0 comentarios
Respuesta aceptada
Star Strider
el 13 de Nov. de 2015
If the values of ‘time_bbdom(:,1)’ are large enough, the ‘exp(-b(3)*time_bbdom(:,1))’ term will be zero, causing the Inf error. Without knowing more, one way to avoid this could be to set the initial value of ‘b(3)’ to ‘max(time_bbdom(:,1))/10’ or some such. You may have to experiment to get the result you want.
7 comentarios
Star Strider
el 17 de Nov. de 2015
The easiest way I can think of to estimate ‘b(1)’ is to take the mean or max of your data. Experiment with both and use the one that works best.
I don’t have your data or the code you used to implement polyfit, so I can’t comment on them.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!