|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
2 t! W4 N; Y8 ]; q$ i+ ~9 P6 }
解题思路:
, T& `3 @7 Z4 X4 O1 e 这种是求解当方程数量多于未知数时,可以使用正规方程来求解。% h) q8 b) A$ @7 I" c o# e6 S
这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。
- i9 h9 d |) e5 W 线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。. ?- z- e* s8 \ i8 s
4 M6 w! g, a1 ]# x6 g- c4 p( j) `代码如下:! ^, E1 o$ p, m: ?
% page 210 computer problem 34 C) M" T5 s! b7 e5 d
% using linearization to evslute the populstion of 1980
; j9 R; F+ G# W" ~1 M# ~' V% Input: None& b% x) Q# ?" R! L) r4 m1 u% p
% Output:None% {6 _4 V6 h3 q
% Display the the result and the error of the caculation9 W# w0 b% g/ s! d) K/ T
function page_210_3
7 y* j- N% @3 i) Z: U* d1 _7 }format long
$ g( [5 `. V" e7 B* W% F# ?A = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为10( L; M; @+ s5 t4 F* a+ d; }0 h' K, A
b = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];& P2 i3 Q" G! d0 O0 v+ H5 X: i
x = ((A')*A)\((A')*b); e& c) I5 f. u
c1 = vpa(exp(x(1)),10)+ C* |: ^$ F0 {' q3 W
c2 = vpa(x(2),6)
! M; }+ b' M4 R# n( y( asyms t;
0 g R6 }( I, S' X' J+ gdisp('使用linearation的方法得到人口的表达式为:');5 s( }3 h8 ?$ o2 O) @
Pt = vpa(c1*exp(c2*(t-1960)),10)
4 ]: _5 T- L' N4 h O! Sdisp('使用linearation的方法估计1980年人口的为:');, O, A. Q8 u, V1 P
Pro_1980 = vpa(subs(Pt,1980),10). Q8 |) z5 n1 i9 u( W; M# f
disp('使用linearation的方法估计1980年人口与实际人口误差为:');
6 M- a5 Q8 h, H# c" @6 h9 ^vpa(abs(Pro_1980 - 4452584592),9) |
|