x=[1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990];y=[3.9 5.3 7.2 9.6 12.9 17.1 23.2 31.4 38.6 50.2 62..9 76.0 92.0 106.5 123.2 131.7 150.7 179.3 204.0 226.5 251.4]; fun=inline('exp(a(1)*t+a(2
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 08:24:40
x=[1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990];y=[3.9 5.3 7.2 9.6 12.9 17.1 23.2 31.4 38.6 50.2 62..9 76.0 92.0 106.5 123.2 131.7 150.7 179.3 204.0 226.5 251.4]; fun=inline('exp(a(1)*t+a(2
x=[1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990];
y=[3.9 5.3 7.2 9.6 12.9 17.1 23.2 31.4 38.6 50.2 62..9 76.0 92.0 106.5 123.2 131.7 150.7 179.3 204.0 226.5 251.4];
fun=inline('exp(a(1)*t+a(2))','a','t')
a=nlinfit(x,y,fun,[0.01 -20])
xx=1790:1990;
yy=exp(a(1)*xx+a(2));
plot(x,y,'o',xx,yy)
z=log(y);
p=polyfit(x,z,1)
z1=polyval(p,x);
y1=exp(z1);
figure
plot(x,y,'*',x,y1)
请问这个哪里出错了?
用指数函数的
x=[1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990];y=[3.9 5.3 7.2 9.6 12.9 17.1 23.2 31.4 38.6 50.2 62..9 76.0 92.0 106.5 123.2 131.7 150.7 179.3 204.0 226.5 251.4]; fun=inline('exp(a(1)*t+a(2
y向量的应该是62.9,写成了62..9了.中间多了一点,记得加分~~~