我正在处理由两个数组组成的曲线拟合数据:
t: 1, 3, 4, 7, 8, 10
P: 2.1, 4.6, 5.4, 6.1, 6.4, 6.6
这两个变量之间的关系由P = mt/(b+t)
给出。我被告知通过将方程与数据点进行曲线拟合来确定常数m和b。这应该通过写出方程的倒数并使用一阶多项式来完成。下面是我的代码:
t = [1 3 4 7 8 10];
P = [2.1 4.6 5.4 6.1 6.4 6.6];
p = polyfit(t, t./P, 1);
m = 1/p(1)
b = p(2)*m
tm = 1:0.01:10;
Pm = (m*tm)./(b+tm);
plot(t,P, 'o', tm, Pm)
书中的答案是m = 9.4157
和b = 3.4418
。上面的代码生成m = 8.4807
和b = 2.6723
。我的错误是什么?任何建议都将不胜感激。谢谢您抽时间见我。
发布于 2013-05-24 18:40:56
要跟进@David_G的评论,看起来你有了更好的答案。实际上,如果你通过MATLAB中的曲线拟合工具箱运行数据,你会得到:
General model:
f(t) = m*t/(b+t)
Coefficients (with 95% confidence bounds):
b = 2.587 (1.645, 3.528)
m = 8.448 (7.453, 9.443)
Goodness of fit:
SSE: 0.1594
R-square: 0.9888
Adjusted R-square: 0.986
RMSE: 0.1996
您的解决方案几乎一样好:
Goodness of fit:
SSE: 0.1685
R-square: 0.9881
Adjusted R-square: 0.9852
RMSE: 0.2053
这两个都比书中的要好:
Goodness of fit:
SSE: 0.404
R-square: 0.9716
Adjusted R-square: 0.9645
RMSE: 0.3178
https://stackoverflow.com/questions/16705730
复制相似问题