求助最小二乘法拟合问题 。
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
labedo
el 24 de Nov. de 2022
Respondida: xejabeh
el 24 de Nov. de 2022
数据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.
请求高手帮助,怎么才能求出参数。
0 comentarios
Respuesta aceptada
xejabeh
el 24 de Nov. de 2022
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!