Matlab之使用linearization估计人口数量

来源:互联网 发布:stc正在检测目标单片机 编辑:程序博客网 时间:2024/04/30 06:12

解题思路:

  •    这种是求解当方程数量多于未知数时,可以使用正规方程来求解。
  •    这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。
  •    线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。


代码如下:

% page 210  computer problem 3% using linearization to evslute the populstion of 1980% Input: None% Output:None% Display the the result and the error of the caculationfunction page_210_3format longA  = [1 0;1 10;1 30;1 40];  %这里的0是以1960年为起点的,所以1970年为10b  = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];x  = ((A')*A)\((A')*b);c1 = vpa(exp(x(1)),10)c2 = vpa(x(2),6)syms t;disp('使用linearation的方法得到人口的表达式为:');Pt = vpa(c1*exp(c2*(t-1960)),10)disp('使用linearation的方法估计1980年人口的为:');Pro_1980 = vpa(subs(Pt,1980),10)disp('使用linearation的方法估计1980年人口与实际人口误差为:');vpa(abs(Pro_1980 - 4452584592),9)


0 0