您的位置:首页 > 编程语言 > MATLAB

Matlab之使用linearization估计人口数量

2014-06-30 01:02 309 查看


解题思路:

这种是求解当方程数量多于未知数时,可以使用正规方程来求解。
这种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 caculation
function page_210_3
format long
A  = [1 0;1 10;1 30;1 40];  %这里的0是以1960年为起点的,所以1970年为10
b  = [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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: