x=[1656,2122,2864,4033,6099];
y=[2112,2170,2291,2456,2759];
[P,S]=polyfit(x,y,1)
%P为拟合回归系数即y=P(1)*x+p(2)
P =1.0e+003 *0.0001 1.8666
S =
R: [2x2 double]
df: 3
normr: 9.4223
>> [Y,delta]=polyconf(P,x,S)
%给出回归Y的95%的置信区间为[Y-delta,Y+delta]
Y =
1.0e+003 *
2.1090 2.1772 2.2858 2.4569 2.7592
delta =
20.6907 19.8923 19.1147 19.2502 23.2005
>> x1=1600:100:6100;
>> f=polyval(P,x1);
>> plot(x,y,\'ro\',x1,f,\'-\')%绘图查看拟合效果
>> hold on
>> plot(x,Y+delta,\'*g\')
>> plot(x,Y-delta,\'*g\')%给出拟合的置信区间