方程两边对数化,得到:ln(y)=ln(a)+b*ln(x),拟合这个线性方程就可以了,使用matlab中的regress()函数,编制如下代码:
x=[5 2 0.9 0.6 0.355 0.15 0.1 0.074]';
y=[0.0318 0.0331 0.0148 0.0165 0.031 0.0284 0.0082 0.0562]';
lnx=log(x);
lny=log(y);
X=[ones(length(x),1),lnx];
format long
[b,bint,r,rint,s]=regress(lny,X,0.05);
b,bint,s,
subplot(2,2,1)
rcoplot(r,rint)
title('残差图')
subplot(2,2,2)
plot(x,y,'+')
title('原始的x-y散点图')
subplot(2,2,3)
plot(lnx,lny,'+')
title('对数化后lnx-lny散点图')
x1=[log(min(x)):0.1:log(max(x))];
y1=polyval(b,x1);
subplot(2,2,4)
plot(lnx,lny,'+',x1,y1)
title('拟合效果图')
format short
得到结果如下:
b =
-3.70894416234909
0.03576915928443
bint =
-4.34859095115185 -3.06929737354633
-0.36781660748507 0.43935492605393
s =
Columns 1 through 3
0.00777750411725 0.04703080699857 0.83549882584920
Column 4
0.41795448690887
注意,统计量中相关性不是很大,你应该考虑换一个模型试试。
温馨提示:答案为网友推荐,仅供参考