|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
( n. F( y, R- ~( D
解题思路:
: o# M s/ B R# G3 r. ?0 A6 S) Z& @" z 这种是求解当方程数量多于未知数时,可以使用正规方程来求解。- V% k4 _( v/ Z
这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。: f. V# n; W, H# d% V& A* o1 q
线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。1 Q' @. A3 ~$ l- o! Y7 a* W
% f) ]8 Z6 P" m Y Q
代码如下:
( f3 @1 L2 i7 F: o" b( y% page 210 computer problem 3
: n" C# M, w! Y8 J T# d% using linearization to evslute the populstion of 1980
( l! ?" F) r) M& d0 a( e% Input: None
# m$ x: ^+ K' w) I' F% U% Output:None
2 t3 E# O! A7 G% P% Display the the result and the error of the caculation" L* W7 j1 U' @ p4 J" [
function page_210_32 F( l- N& N+ U7 S6 _
format long
+ \7 f* u& y& AA = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为10
- Y: n3 I. V; x' |6 h: ?0 ^( Ub = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];
; J1 B( P& e' R/ {x = ((A')*A)\((A')*b);
& E4 o3 i: Q( y: ic1 = vpa(exp(x(1)),10)9 }6 ]5 d, `* k9 ]7 e
c2 = vpa(x(2),6): O6 a O* ~- }- x
syms t;
( V( k0 F' t! V7 |! `disp('使用linearation的方法得到人口的表达式为:');
2 o% ^- q! C1 k/ V! a2 Y2 @/ pPt = vpa(c1*exp(c2*(t-1960)),10)
9 f( P, V8 M1 I. c9 Gdisp('使用linearation的方法估计1980年人口的为:');
7 l) H5 k" ~# G- o5 V( ~+ S# fPro_1980 = vpa(subs(Pt,1980),10). \1 T6 A: {7 V& `- W ~: J
disp('使用linearation的方法估计1980年人口与实际人口误差为:');
* f7 i" p$ F# W3 q4 h2 D1 f$ J' {vpa(abs(Pro_1980 - 4452584592),9) |
|