MATLAB参数拟合
数据x:1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 2000
数据y:15.1764871110999 15.4832173785224 15.7895915839863 16.0772736564381 16.3727378693319 16.6545890214729 16.9596628366365 17.2623184508785 17.4687628344351 17.7315255846620 17.9570567216707 18.1462438982506 18.3372991350133 18.4836555431138 18.6293196090637 18.6960371667135 18.8308016635967 19.0045709385754 19.1336305518085 19.2382555028874 19.3425558541204 19.4552877026446
求用matlab拟合参数r,使得
其中,x0,y0是数据中的第一个数 展开
下面是我的个人看法,学艺不精,希望也能对你有帮助,有疑问我们再交流,祝生活愉快!
因为你这个拟合要求过起始点,而Matlab的线性模拟可以直接给出斜率和截距,如果非要用你的那个公式,那就仍然采用之前的斜率,相当于平移了,但图像上就不是很好了。
代码:
x=[1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 2000];
y=[15.1764871110999 15.4832173785224 15.7895915839863 16.0772736564381 16.3727378693319...
16.6545890214729 16.9596628366365 17.2623184508785 17.4687628344351 17.7315255846620...
17.9570567216707 18.1462438982506 18.3372991350133 18.4836555431138 18.6293196090637...
18.6960371667135 18.8308016635967 19.0045709385754 19.1336305518085 19.2382555028874...
19.3425558541204 19.4552877026446];
plot(x,y,'r')
hold on
p=polyfit(x,y,1)
z1=p(1)*x+p(2);
z2=p(1)*(x-x(1))+y(1);
plot(x,z1,'b',x,z2,'k')
legend('红色原来曲线','蓝色直接模拟曲线','黑色平移曲线')
输出结果:
p =
0.0202 -20.5779
2024-08-07 广告