How to fit a custom equation?
조회 수: 5 (최근 30일)
이전 댓글 표시
My equation is y=a(1-exp(-b(c+x)) x=[0,80,100,120,150] y=[2195,4265,4824,5143.5,5329] When I am solving it in matlab, I am not getting a proper fit in addition, sse=6.5196e+05 and r square=0.899. Although the r square value is acceptable, the sse is too high. Therefore kindly help to get minimum sse. Further I have tried in curve fitting tool but I got same thing.
댓글 수: 0
채택된 답변
Star Strider
2018년 7월 9일
I get good results with this:
yf = @(b,x) b(1).*(1-exp(-b(2)*(b(3)+x)));
B0 = [5000; 0.01; 10];
[Bm,normresm] = fminsearch(@(b) norm(y - yf(b,x)), B0);
SSE = sum((y - yf(Bm,x)).^2)
Bm =
6677.76372320411
0.0084077646869843
47.1622210493944
normresm =
195.173589996072
SSE =
38092.7302319547
댓글 수: 7
Star Strider
2018년 7월 11일
There isn’t. You’re ignoring the constant multiplication factor 1.0E+03. The full result:
p =
1.0e+03 *
-0.000088159928538 0.034559355475118 2.180742845451099
추가 답변 (2개)
Image Analyst
2018년 7월 11일
For what it's worth, I used fitnlm() (Fit a non-linear model) because that's the function I'm more familiar with. You can see it gives the same results as Star's method in the image below. I'm attaching the full demo to determine the coefficients and plot the figure.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189874/image.png)
댓글 수: 0
Alex Sha
2020년 2월 18일
If don't care the type of fitting function, try the below function, much simple but with much better result:
y = b1+b2*x^1.5+b3*x^3;
Root of Mean Square Error (RMSE): 18.0563068929128
Sum of Squared Residual: 1630.15109305524
Correlation Coef. (R): 0.999873897456616
R-Square: 0.999747810815083
Adjusted R-Square: 0.999495621630167
Determination Coef. (DC): 0.999747810815083
Chi-Square: 0.165495427247465
F-Statistic: 3964.27710070773
Parameter Best Estimate
---------- -------------
b1 2195.84396843687
b2 3.66989234203779
b3 -0.00107101963512847
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/272395/image.jpeg)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!