从 1790 年到 1900 年:
>>x=0:11;
>>y=[ 3.9000 5.3000 7.2000 9.6000 12.9000 17.1000 23.2000 31.4000
38.6000 50.2000 62.9000 76.0000 ];
>>fun=inline('exp(a(1)*t+a(2))','a','t');
>> a=nlinfit(x,y,fun,[0.01 -20])
a =
0.2547 -18.6728
>> xx=0:11;
>> yy=exp(a(1)*xx+a(2));
>> z=log(y);
>> p=polyfit(x,z,1)
p =
0.2743 1.4323
>> z1=polyval(p,x);
>> y1=exp(z1)
y1 =
Columns 1 through 9
4.1884 5.5105 7.2498 9.5382 12.5488 16.5097 21.7209 28.5769 37.5969
Columns 10 through 12
49.4640 65.0769 85.6179
>> plot(x,y,'*',x,y1)
评论4