How to improve the fitting result
이전 댓글 표시
Hellow, there!
I am doing a fitting using quite involved custom equation. The definition of the function is as below:
function bif = bifit(A,bix,a,x,e,k,T)
fun = @(bix,b,a,x,e,k,T) exp(-b.^2./(2.*a.^2)).*heaviside(bix-x-b-e).*exp(-(bix-x-b-e)./(k.*T));
bif = integral(@(b) fun(bix,b,a,x,e,k,T),-1,1,'ArrayValued',1).*A;
end
Also, the code for fitting is as below:
ft = fittype('bifit(A,bix,a,x,e,k,T)','problem',{'x','k','T'},'independent','e'...
,'coefficients',{'A','bix','a'});
fo = fitoptions(ft);
fo.StartPoint = [129400 5.98470 0.01219];
fo.Lower = [120000 5.90000 0.00800];
fo.Upper = [300000 6.10000 0.13000];
bi = fit(data_x,data_y,ft,fo,'problem',{3.0169,8.61773*10^-5,161})
bi_coeff = coeffvalues(bi)
plot(bi,data_x,data_y,'-'),legend('exp','bi','location','Northeast')
'data_x' & 'data_y'(429x1 double respectively) are both column vector type data imported from excel file.
'e'(429x1 double) is a number type array(or matrix) data also imported from excel file.
The problem is that the result of the fitting returns the plot as shown below, which clearly does not fit the data:

The fitting should be as shown below:

The coeffvalues() returns the coefficient values as below, but it should be 129406 5.98480 0.01220 for the fit to look like the plot right above.
bi_coeff =
1.0e+05 *
1.2018 0.0001 0.0000
Thus, I was thinking to get a better fitting, I might need to extend the significant digit, or to bounds the x-axis value.
Any advice to improve the result of the fitting? Thanks a lot in advance!
채택된 답변
추가 답변 (1개)
Matt J
2021년 2월 10일
0 개 추천
Discard the data corresponding to data_x>2.98. Clearly, you do not want that to participate in the fit.
댓글 수: 2
Wonkyung Choi
2021년 2월 10일
편집: Wonkyung Choi
2021년 2월 10일
Matt J
2021년 2월 10일
Discard the data from the fit only
keep=data_x<2.98;
bi = fit(data_x(keep),data_y(keep),ft,fo,'problem',{3.0169,8.61773*10^-5,161});
plot(bi,data_x,data_y,'-'),legend('exp','bi','location','Northeast')
카테고리
도움말 센터 및 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!
