|
|
发表于 2014-7-14 00:28:29
|
显示全部楼层
|
matlab 二阶微分方程- l! t" S% T. b% u& F, Q
! x9 l% ?8 _3 i& ]( o3 d
>> clear- M. n+ b( B1 w) e3 _% W+ l- z
>> syms a b c d e;
5 V. `& X- p% l' ~9 ~/ d/ [>> y=dsolve('a*D2y+b*Dy+c*y=0','y(0)=d','Dy(0)=e')& q6 ^$ v' Z- n8 {
& g/ b* ~1 V/ V6 r* T7 l) o' l
y =4 }* e5 i. m0 V: H
1 t$ j5 Y; ^: O: p(2*a*e + b*d + d*(b^2 - 4*a*c)^(1/2))/(2*exp((t*(b - (b^2 - 4*a*c)^(1/2)))/(2*a))*(b^2 - 4*a*c)^(1/2)) - (2*a*e + b*d - d*(b^2 - 4*a*c)^(1/2))/(2*exp((t*(b + (b^2 - 4*a*c)^(1/2)))/(2*a))*(b^2 - 4*a*c)^(1/2))9 }1 n# K& R8 P0 p& K4 O
* S+ |7 {3 i; D C% o7 T
>> a=1;b=1;c=1;d=1;e=1;%若常数已知
$ a" D1 N; K, _: ?5 t. E: M
3 s4 C, G, \; Z/ D>> t=1;%desolve中没指定自变量x,这里默认为t,带入任意一个x值
0 P4 j6 g5 n6 a8 M3 g$ i>> y=eval(y) / C" P& h' {( R, M3 n2 M& e
" p/ v4 _: t/ ~. p
y =- W$ m/ l& n7 q+ J, G! Z- y
! e- s: n# U/ s. Q' ? 1.1932 + 0.0000i/ ^- w) J/ J, {
这是解方程的方法,画图也差不多,我在命令窗写的改麻烦,下面是我在editor写的。
& Y+ A. y. _& v/ M+ M; Isyms a b c d e;4 r5 P: U9 Q3 ~ f: G+ ^* P
y=dsolve('a*D2y+b*Dy+c*y=0','y(0)=d','Dy(0)=e','x');
5 M" a T, J3 W, Nx=200:0.1:400;%取值范围,步长
8 A9 o$ f* i; O8 {1 {a=1;b=1;c=1;d=1;e=1;%带入参数
: r* }& t; @2 @y=eval(y);7 k9 q% P! i/ `7 {
plot(x,y) |
|