|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
8 D* ~+ K) `* G$ S4 g
解题思路:1 b$ ~. S# {/ r4 W6 |9 b3 R
这种是求解当方程数量多于未知数时,可以使用正规方程来求解。 K/ t* b+ c+ O
这种linearization方法是将pt = c1*e^(c2*t),两边取ln得到线性方程组。8 Z5 Q/ l4 R& S& L* Z
线性化之后呢就要进行方程求解,也就是A'Ax = A'b,那么使用x = ((A')*A)\((A')*b);就可以求出x的值,也就是lnc1和c2的值。记得一定要像上面那样写,A'*A在前面,A'*b在后面。
, ~& J' e# X( H0 r: e/ {& J2 v, V5 i/ \, |4 U# P4 \) \% f4 R7 t. \
代码如下:
& m, B5 h; G U/ l; D9 S2 P8 ]. m$ [7 a% page 210 computer problem 3% a9 y$ Z# A* \9 _$ [+ q, C
% using linearization to evslute the populstion of 19804 f" s) j- {8 V8 [! G0 d* S% ^4 V
% Input: None
' V. {6 y* {+ s! h& z7 H% Output:None! Z0 L* @! |" b+ ?8 ^+ b
% Display the the result and the error of the caculation/ P4 [7 h" ?$ o- h& o
function page_210_31 i1 o5 w6 S3 L5 Q/ z
format long$ X7 @0 ]7 h' h. ^; b* x" W
A = [1 0;1 10;1 30;1 40]; %这里的0是以1960年为起点的,所以1970年为10- G; z2 r. _0 \6 _, h
b = [log(3039585530);log(3707475887);log(5281653820);log(6079603571)];/ v" G/ f2 p& z; q) S* X
x = ((A')*A)\((A')*b);
8 M+ \6 C! H9 ec1 = vpa(exp(x(1)),10)
) t/ M, W1 P; s& f* Rc2 = vpa(x(2),6)4 f$ v% v$ V. K$ T7 g5 [/ r$ P
syms t;+ D; r, I: O5 B3 t- Z" U
disp('使用linearation的方法得到人口的表达式为:');
! C0 ^0 Q7 A/ s0 s1 ~8 H# J4 _4 ^Pt = vpa(c1*exp(c2*(t-1960)),10)1 y, N8 I9 i' ], Z' G& O( g
disp('使用linearation的方法估计1980年人口的为:');
' r* M# C4 F; c8 @Pro_1980 = vpa(subs(Pt,1980),10)' M+ ?" y; W# j! [9 y4 s8 s4 w
disp('使用linearation的方法估计1980年人口与实际人口误差为:');
4 _9 y/ D2 i F Gvpa(abs(Pro_1980 - 4452584592),9) |
|