|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
! `* g: c$ \5 ^1 G; i
解题思路:
# {5 [2 i, f+ B' u, M/ v 这种是求解当方程数量多于未知数时,可以使用正规方程来求解。
4 i/ g' n$ r4 M% l 这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。
+ ^( q( W$ e7 n' z; K8 Z5 j: | 线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。
0 Q F# t' y' t% d8 X8 s: o2 i2 _: Y& ^9 ~9 O3 Z( w) s% Q
代码如下:; |& o3 F7 g0 d0 X+ A" j' f/ {9 _4 a- f
% page 210 computer problem 3
5 I6 j4 d4 q C9 X% using linearization to evslute the populstion of 19801 i! E* X) D' ^, t. r4 J4 V9 a
% Input: None
2 }7 N9 D( A S: n( c4 a, b% Output:None' z: L: ~# I) U
% Display the the result and the error of the caculation
& ~& j5 F! n5 Pfunction page_210_38 L7 L: f8 ]6 ~$ e6 G
format long7 j- Z+ f! ?0 G- U
A = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为10
: h$ s \. p4 d; c o5 j3 ub = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];0 F; D m( A* ]: [1 r3 b- L+ v
x = ((A')*A)\((A')*b);
% c6 _6 e# V6 I. C% p) m: B( c1 [c1 = vpa(exp(x(1)),10)( Q5 D w2 y# j; u
c2 = vpa(x(2),6)
, ?+ K, z/ w; [8 r$ `syms t;$ S: b0 {" C( _0 Z) w0 i* N8 C& P
disp('使用linearation的方法得到人口的表达式为:');% F2 G5 j+ X! T
Pt = vpa(c1*exp(c2*(t-1960)),10)
5 H5 k9 S9 x$ A, g2 H2 hdisp('使用linearation的方法估计1980年人口的为:');
) I8 F$ G0 V/ M2 w& b- tPro_1980 = vpa(subs(Pt,1980),10)1 o1 N$ n+ E9 V" z2 @1 f
disp('使用linearation的方法估计1980年人口与实际人口误差为:');
7 I! o- ~( ]6 u/ v" w! evpa(abs(Pro_1980 - 4452584592),9) |
|