|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
( _3 G) o+ R+ k- ^9 I
解题思路:
, L% p9 w% T' k4 _1 v9 J 这种是求解当方程数量多于未知数时,可以使用正规方程来求解。- ^# J4 |2 m$ Z4 N+ W1 A. T2 J
这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。
: a) p9 ~ v2 Z- h" U1 q 线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。
, E+ o# f/ v1 u
! q( Q G) E- q- R代码如下:9 ?! O& s6 p) p. I( O& m& t1 M
% page 210 computer problem 3
" }, C1 X) ^1 h* b d% using linearization to evslute the populstion of 1980
) k% j1 i. x4 B! Z% s/ [% Input: None S; p$ g. V% i8 y& o* z
% Output:None
$ G( c' N/ B. T4 k; O, S% Display the the result and the error of the caculation
7 h- B0 z$ [( U/ a6 h& o% @function page_210_3
5 Z) z ~& f$ e6 Y+ fformat long
* p" x8 u" ^0 x* bA = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为10
. _' h' j% i8 L- I1 y- D j0 O( `0 db = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];
5 [% t( W6 Y$ ^6 E' |, f; Ux = ((A')*A)\((A')*b);
3 j, x3 ~6 S$ M% O3 W1 K: y- uc1 = vpa(exp(x(1)),10)
( r& T( O t& N: t7 l9 gc2 = vpa(x(2),6)
9 _- a; k. u2 g6 P4 r" Ysyms t;, `( l" h& X$ A8 N5 T/ `3 Z
disp('使用linearation的方法得到人口的表达式为:');6 a. ]1 V0 q2 k% N3 z, O
Pt = vpa(c1*exp(c2*(t-1960)),10)
% i1 m* [: i2 H5 h. Z# j- |disp('使用linearation的方法估计1980年人口的为:');
' @; }8 w8 z/ U- f. u! yPro_1980 = vpa(subs(Pt,1980),10)0 A- C5 P9 B8 |6 V
disp('使用linearation的方法估计1980年人口与实际人口误差为:');
! F. O9 z0 e( Pvpa(abs(Pro_1980 - 4452584592),9) |
|