|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
5 n! b+ e7 r( L1 ]% I9 ~解题思路:# Y" h o, V6 x `
这种是求解当方程数量多于未知数时,可以使用正规方程来求解。# e+ E+ I# k& K/ l
这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。2 W! O0 t$ u: ^* b8 |1 k
线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。
9 S* p5 t: r# e$ ^4 `
$ ~: s h7 a. B5 ]5 M代码如下:- r/ E( `! I h& b
% page 210 computer problem 3
3 H& Z8 a. E$ b" ~) T5 f, U% using linearization to evslute the populstion of 1980
4 s/ A5 I& I m: ^% Input: None0 P% y* m8 j( ^+ Z2 p% H
% Output:None
! J# q* E% a2 X& R u( q3 C* E( t% Display the the result and the error of the caculation
2 A/ _; W, n) @( f: bfunction page_210_3. P, N" `; c, n5 v8 w, q
format long5 K4 Q' u# c- q8 [* A( ]
A = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为10$ I2 M/ H. t7 e: d% E
b = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];
% B7 k" {4 W. Ox = ((A')*A)\((A')*b);& O# L+ G$ j4 Z, ~
c1 = vpa(exp(x(1)),10)
N/ p% P/ V: A% tc2 = vpa(x(2),6)* C2 N4 r3 K. A& o' W
syms t;
0 H# t' h: o2 S0 Q. hdisp('使用linearation的方法得到人口的表达式为:');3 @/ n" ~% T7 P: o7 p( n, V
Pt = vpa(c1*exp(c2*(t-1960)),10)( Y. L4 |2 ]) D) d) ]. N
disp('使用linearation的方法估计1980年人口的为:');) K& ]' }/ S2 d6 c5 H
Pro_1980 = vpa(subs(Pt,1980),10)! `) X& A9 W$ z; L3 v# H
disp('使用linearation的方法估计1980年人口与实际人口误差为:');
( N! P7 g3 X- @vpa(abs(Pro_1980 - 4452584592),9) |
|