Initial guess does not change in MATLAB fitting tool
조회 수: 8 (최근 30일)
이전 댓글 표시
I am trying to fit a simple gaussian from very few raw data (a set of x points and y points) with the curve fitting tool implemented in MATLAB (i.e. the simple curve f(x) = a1*exp(-((x-b1)/c1)^2)). It uses the default non linear least squares method.
Now, I want to keep the coefficient c1 fixed, while I let the coefficients a1 and b1 moving, so I can find a good guess for height and centroid. The problem is, whichever algorithm I apply, the coefficient b1 does not move at all from its initial start point, regardless of which point it is! For example, look at the data: evidently, the centroid should go ultimately between x=3.95 and x=4. However, if I put the start point at, for example, 4.1, it will not move from there, and the fitted curve will be evidently wrong.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/547548/image.png)
Even if I put a realistic starting point for b1, for example 3.96, still it will not move. The fit will be more realistic, but I still the algorithm will not have worked properly, since it appears that it does not search at all which should be the final best guess for b1.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/547553/image.png)
Any ideas? Thank you in advance!
댓글 수: 1
Alex Sha
2021년 3월 13일
It is because the optimizations algorithms applied in Matlb curve-fitting tool are all local optimization algoritjms, not global optimization algorithms, therefore, the task of guessing the initial start-value is unavoidable, and the reasonable initial value depends on your experience and luck.
채택된 답변
Matt J
2021년 3월 13일
편집: Matt J
2021년 3월 13일
The order of magnitude of your Y-Data is (~1e-5) is close to the default TolFun stopping parameter. This makes the algorithm prone to early stopping. Try scaling the Y-Data to be ~1e0.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!