|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
* x! Q! ~" J5 n) S% M7 z& e
解题思路:. S& E$ q( a9 b% p0 m7 Q
这种是求解当方程数量多于未知数时,可以使用正规方程来求解。( `4 M/ t' Y2 O7 B6 F! K
这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。/ R$ G, t# s5 ~' _) H! `+ _
线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。
$ C' f5 d* o; x2 f* d% w
6 \( q/ i' ?' K7 D! \# K( I2 [代码如下:
3 c5 g( w; e T6 ^5 S. @" y ~% page 210 computer problem 3
1 T! T5 }; C; o+ i+ D% using linearization to evslute the populstion of 19809 p3 P; ]; F/ r! h! f {7 {
% Input: None* k0 }% S) m$ ^; s( b% p8 m L
% Output:None, ^# \" z4 O3 F" n. m
% Display the the result and the error of the caculation+ o* J8 [2 Y+ J6 a# \2 H
function page_210_3
) o F& f/ ?) ?5 ~4 e1 ?format long
. O1 f9 ]0 a O6 \; c& rA = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为103 T: B2 }4 f% x3 c3 T+ g! u
b = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];
" h% ]/ \% d# }+ N( `x = ((A')*A)\((A')*b);
& G( r' @9 u: t, R/ zc1 = vpa(exp(x(1)),10)
: A9 D9 @, v" `! {" a' Vc2 = vpa(x(2),6)2 |% c# ~5 a- O) Y, p8 |+ |9 b( C
syms t;3 X, g5 Q, E1 b0 p+ d
disp('使用linearation的方法得到人口的表达式为:');$ r$ i0 M6 A7 z7 M
Pt = vpa(c1*exp(c2*(t-1960)),10)2 b: ]( u: e1 \$ f7 }6 @- T, r/ b$ e
disp('使用linearation的方法估计1980年人口的为:');* T v; I: K. S+ @$ V- r# X
Pro_1980 = vpa(subs(Pt,1980),10)1 U: C `. f$ ^9 N1 ]% V
disp('使用linearation的方法估计1980年人口与实际人口误差为:');
& F: g& z* F+ Z' Evpa(abs(Pro_1980 - 4452584592),9) |
|