Improve initial values lsqcurvefit

조회 수: 5 (최근 30일)
Matthew
Matthew 2016년 6월 3일
댓글: Alan Weiss 2016년 6월 6일
I would like to improve the initial value guess x0 for lsqcurve fit. I need to be able to do it automatically without changing the values in the script. Is there a way to do this?
I need to be able to fit multiple curves so its not practical to change the initial values by hand. My code looks like
%%----------------EXAMPLE CODE
b0=[mean(data),data(1,1),0,1,1,1]; %<------WANT TO AUTOMATE THIS LINE TO IMPROVE FIT, SPECIFICALLY THE LAST 4 NUMBERS
fun_model=@(b,time)b(1)+b(2)*exp((b(3)*(1+b(4)...
*(log(time)).^(-b(5)))).^(2));
fit=lsqcurvefit(fun_model,b0,time,data,lb,ub,'options')
%%----------------

채택된 답변

Alan Weiss
Alan Weiss 2016년 6월 3일
If you have Global Optimization Toolbox, you can use MultiStart to generate multiple initial points randomly within finite bounds, as in this example.
It is also not hard to generate such points yourself:
x0 = lb + rand(size(lb)).*(ub - lb);
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 2
Matthew
Matthew 2016년 6월 6일
So I have started trying to use Multistart and I get this error
Error using CustomStartPointSet (line 78)
A single input can be a CustomStartPointSet or a real matrix containing
at least one start point.
Not sure whats happening
Alan Weiss
Alan Weiss 2016년 6월 6일
It appears that you are trying to use an invalid custom start point set. Either show us how you are generating and using the custom start points, or do not use custom start points.
Alan Weiss
MATLAB mathematical toolbox documentation

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by