|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
9 [* y T: A i9 ?$ a! G3 ]0 M V
解题思路:
: D8 Y6 ]4 J3 B! N* e 这种是求解当方程数量多于未知数时,可以使用正规方程来求解。8 x/ u' O0 E- S$ [ L5 u8 g$ ]
这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。
6 b. v& d6 S4 H; B, c 线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。
: y* C8 J2 m) w- @( E
/ G! W8 h) g& l+ k4 b代码如下:' f0 Y! c$ i5 U0 \% n7 L" l
% page 210 computer problem 3
2 s9 A9 a. g% }2 q5 C- W2 F& T% using linearization to evslute the populstion of 19801 K1 d/ ?/ h0 y- S- _
% Input: None
4 t2 r' S9 b! q+ V( @2 ]% Output:None
, L# B \2 r4 s% `% Display the the result and the error of the caculation s4 i: P1 `8 e1 Z0 x
function page_210_39 k' ]# X+ w0 W0 C3 C) m
format long
5 O1 K3 [& b- t) kA = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为107 }' B( o: h$ |
b = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];- |6 ~4 S2 H3 n
x = ((A')*A)\((A')*b);
/ [8 w# c s4 {" W( n* `c1 = vpa(exp(x(1)),10)/ y2 C3 m. D' d- Z# d/ L6 q5 k% ?7 L
c2 = vpa(x(2),6)4 o% H' Q/ a5 e6 s! y
syms t;5 Q5 P5 j1 W( k" D
disp('使用linearation的方法得到人口的表达式为:');5 s z# P$ M% Y9 N9 q- h
Pt = vpa(c1*exp(c2*(t-1960)),10)! a r" ^6 X: r7 V& {3 I$ r- g# {
disp('使用linearation的方法估计1980年人口的为:'); U/ p/ t' W C$ B( g% ]
Pro_1980 = vpa(subs(Pt,1980),10); m8 y" k, P$ R5 Y! _# m3 J/ [+ A: I" [
disp('使用linearation的方法估计1980年人口与实际人口误差为:');
2 u+ z3 k$ I9 f8 n ]9 b3 X0 D$ ?! vvpa(abs(Pro_1980 - 4452584592),9) |
|