|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
: ^8 f- T* l+ b& p0 Q) M
解题思路:
8 H G7 l$ b1 Z7 o, n1 W7 z0 I 这种是求解当方程数量多于未知数时,可以使用正规方程来求解。
6 F' w6 L1 S& |. I7 p 这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。
3 J7 t) v/ \3 i" t% |7 k) t$ P3 J 线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。
d7 f$ W6 h2 H
/ ~; Q4 d H3 U) i代码如下:
& F. x4 W" B- x, z3 a0 Z `. i% page 210 computer problem 3
' a t2 E% ~/ ]. p1 P; f; c4 a% using linearization to evslute the populstion of 1980$ O5 I8 ]1 Z' t4 g
% Input: None- j u% Y5 }( ]3 K- d6 R0 u
% Output:None
/ l4 {, o- V/ H% H9 `- T$ Z% Display the the result and the error of the caculation
: n) ~* Y) ]1 [$ E7 Gfunction page_210_3
6 U4 V( J! B2 A9 t8 Q0 {format long
$ |1 z4 m7 U3 P/ O% W# ?+ ]" U! J& `A = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为10
7 D4 q5 T- Q6 p5 R. B- a. l! qb = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];
0 l, x1 P+ g* X- V) c! C9 Qx = ((A')*A)\((A')*b);
) }4 N) U1 r5 {; w4 T/ O/ s, u8 Mc1 = vpa(exp(x(1)),10)
2 L' e B7 u" h l2 Z# Kc2 = vpa(x(2),6). l0 [5 @. f5 @0 i$ _6 K- x" H
syms t;
. E+ m5 P. N* o. P Z' O) Pdisp('使用linearation的方法得到人口的表达式为:');" {/ {$ _% k5 x0 ?' J
Pt = vpa(c1*exp(c2*(t-1960)),10)" s- H9 P B2 R e8 f' x% g
disp('使用linearation的方法估计1980年人口的为:');
; X; |& g+ M1 o/ q# J* APro_1980 = vpa(subs(Pt,1980),10)
+ H! v! b/ }0 V8 }( U0 r0 Kdisp('使用linearation的方法估计1980年人口与实际人口误差为:');) Q" {" q2 C) y$ C! c0 ?, P
vpa(abs(Pro_1980 - 4452584592),9) |
|