求助最小二乘法拟合问题 。

조회 수: 15 (최근 30일)
labedo
labedo 2022년 11월 24일
답변: xejabeh 2022년 11월 24일
数据xdata=[50 100 150 400 800];
ydata=[0.797595 0.754736 0.718371 0.555379 0.411674];
带拟合函数:y=(1-f)*exp(-b*x)+f*exp(-c*x).
当x大于200时,c可以或略不计,此时先拟合b,然后把b作为常数带人函数,用全部xdata拟合f和c.
我用curve fit工具箱custom equation拟合时出现Warning: A negative R-square is possible if the model does not contain a constant term and the fit is poor (worse than just fitting the mean). Try changing the model or using a different StartPoint.
请求高手帮助,怎么才能求出参数。

채택된 답변

xejabeh
xejabeh 2022년 11월 24일
Matlab 当然是可以的
xdata=[50 100 150 400 800];
ydata=[0.797595 0.754736 0.718371 0.555379 0.411674];
[z,gof] = fit(xdata.',ydata.', @(b, c, f, x) (1-f)*exp(-b*x)+f*exp(-c*x), ...
             'StartPoint', [0.001, 0.001, rand], ...
             'Lower', [0, 0, 0], ...
             'Upper', [Inf, Inf, 1])
plot(xdata,ydata,'b-',xdata,z(xdata),'r-')
legend('data','fit')
z =
General model:
z(x) = (1-f)*exp(-b*x)+f*exp(-c*x)
Coefficients (with 95% confidence bounds):
b = 0.0008864 (0.0006362, 0.001137)
c = 0.04651 (-0.05451, 0.1475)
f = 0.1836 (0.1099, 0.2573)
gof =
sse: 4.4622e-04
rsquare: 0.9957
dfe: 2
adjrsquare: 0.9913
rmse: 0.0149
[attach]124464[/attach]

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!