How to get parameter values from lsqcurvefit?

I have been using lsqcurve fit to calculate two parameters so that my model fits my experimental data more accurately. I have written code and keep getting the exit message:
"Local minimum found.
Optimization completed because the size of the gradient is less than the default value of the function tolerance."
Does this mean the programme has succeeded? How do I get the values for my two parameters?
Thanks

답변 (1개)

Star Strider
Star Strider 2016년 3월 17일
편집: Star Strider 2016년 3월 17일

0 개 추천

Your estimated parameters are ‘x’ in this example from the documentation:
x = lsqcurvefit(fun,x0,xdata,ydata)
The warning (not error) indicates that lsqcurvefit has found a local minimum, not the global minimum that would produce the best parameter estimates. Use different initial parameter estimates (in this example, ‘x0’) and see if that produces a better fit. Another option is to use fminsearch, since it uses a derivative-free method, and sometimes succeeds when the gradient-descent solvers do not. If you have the Global Optimization Toolbox, the patternsearch function may find the global minimum most efficiently.
Example code using fminsearch:
x = ...; % Independent Variable
y = ...; % Dependent Variable
fun = @(b,x) ...; % Objective Function
SSECF = @(b) sum((y - fun(b,x)).^2); % Sum-Squared-Error Cost Function
B0 = [...]; % Initial Parameter Estimates
B = fminsearch(SSECF, B0); % Estimate Parameters
Here, ‘B’ would be the estimated parameters.

카테고리

도움말 센터File Exchange에서 Nonlinear Least Squares (Curve Fitting)에 대해 자세히 알아보기

질문:

2016년 3월 17일

편집:

2016년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by