Best Curve-Fitting Function

조회 수: 39 (최근 30일)
Owen Cheevers
Owen Cheevers 2022년 7월 7일
댓글: Owen Cheevers 2022년 7월 7일
There seems to be a ton of options available on MATLAB for curve-fitting, and I was wondering if there was an easy way to determine what function/ approach was best if I'm trying to fit a non-linear function with multiple unknown parameters to a data-set.
If it helps, the non-linear functional form I'm looking at for the moment is where a and b are the varying parameters, x is the input data and y is the response data.

채택된 답변

John D'Errico
John D'Errico 2022년 7월 7일
편집: John D'Errico 2022년 7월 7일
The "best" solver? Ii is the one you have access to, and the one you know how to use.
Fit is easy to use.
mdl = fittype('1/(a + b*x)','indep','x');
ab0 = [ ... ];
fittedmdl = fit(x,y,mdl,'start',ab0)
I've not supplied anything for ab0, since I don't have your data, or even a picture of it. But expect possibly bad results if you supply nothing, even though fit does not technically require starting estimates.
Oh, and fit needs the data to be in the form of COLUMN vectors, so x and y must both be column vectors.
Finally, you could probably obtain good starting values for the model:
1./y = a + b*x
using one line of code as:
ab0 = flip(polyfit(x(:),1./y(:),1));
While this would produce estimates of the parameters, I would point out that it does not properly deal with the error structure in the problem. But to then use those pre-estimates as starting values for fit, would probably be entirely reasonable. The flip in there is important, becausse polyfit will return the parameters in the wrong order for what fit will be expecting.
  댓글 수: 1
Owen Cheevers
Owen Cheevers 2022년 7월 7일
Thanks for the detailed answer!
Just as a follow-up question, if that's alright, I was wondering if the mdl argument for fit corresponded to what the equation you're trying to fit to is. From the looks of your answer and the use of fittype, that was my impression.
I was just confused by the documentation, as that only seems to talk about incrementalClassificationECOC, and I was unsure of what that was or if it had to be used as the mdl argument instead.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by