一次函数:(a+bx = y)
%先求出拟合函数
format long;
x = [2001 2002
];
y = [32.2 31.3
29.7 28.6 27.5 26.1 25.3 23.7 22.7];
d = [1 1 1 1 1 1 1 1
1];
a=[d;x];
b = a*y';
a=a*a';
c=ab
c =
1.0e+003 *
2.436797222221444
-0.00166666666
%所以,拟合函数为
y = 1.0e+003
*(2.436797222221444 - 0.00166666666*x
%根据拟合函数求估测值
format short;
x = [, , ,
,
]
1.0e+003
*(2.436797222221444 - 0.00166666666*x)
ans
=
21.4472
20.2456
19.0439
17.8422
16.6406
指数函数:( y = exp(a +
b*x))
>> x = [2001
2002 ];
y =
[21.515.9 11.8
8.76.54.83.52.62.0];
y=log(y');
d = [1 1 1 1 1 1 1 1
1];
a=[d;x];
b = a*y;
a=a*a';
c=ab
c =
601.9448
-0.2993
%所以,拟合函数为 y = exp(601.9448 -
0.2993*x)
%根据拟合函数求估测值
>>x =
[, , , ,]
exp(601.9448 -
0.2993*x)
ans =
1.42161.05390.78130.57920.4294
双曲线: (1/y = a +
b/x)
format long;
x =
[2002 ];
y = [46.232.626.723.020.018.917.516.3];
t=1./x;
u = 1./y';
d = [1 1 1 1 1 1 1 1];
a = [d; t];
b = a*u;
a=a*a';
c=ab
c =
1.0e+004 *
0.001110403638151
-2.218020870743078
format short;
x = [, , ,
,]
x./(1.0e+004 *
(0.001110403638151*x -2.218020870743078))
ans =
14.470413.405912.488211.688810.9862