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

14 ビュー (過去 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 Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!