matlab解微分方程的问题
matlab解微分方程的问题
4x”+35.78x’+2000x=F(t)
F(t)=100 0
似乎还缺初始条件啊
function hh
x0=[10 5];
[T1,X1] = ode45(@odefun1,0:0.01:0.1,x0)
[T2,X2] = ode45(@odefun2,0.1:0.01:0.2,[X1(end,1),X1(end,2)])
plot(T1,X1,T2,X2)
function dx=odefun1(t,x)
x1=x(1);x2=x(2);
dx1=x1;
dx2=(1000-35.78*x1-2000*x2)/4;
dx=[dx1;dx2];
function dx=odefun2(t,x)
x1=x(1);x2=x(2);
dx1=x1;
dx2=(1000*(t-0.2)-35.78*x1-2000*x2)/4;
dx=[dx1;dx2];
结果:
T1 =
0
0.0100
0.0200
0.0300
0.0400
0.0500
0.0600
0.0700
0.0800
0.0900
0.1000
X1 =
10.0000 5.0000
10.1005 0.3512
10.2020 0.3181
10.3045 0.3160
10.4081 0.3138
10.5127 0.3124
10.6184 0.3104
10.7251 0.3087
10.8329 0.3066
10.9417 0.3047
11.0517 0.3027
T2 =
0.1000
0.1100
0.1200
0.1300
0.1400
0.1500
0.1600
0.1700
0.1800
0.1900
0.2000
X2 =
11.0517 0.3027
11.1628 -0.2416
11.2750 -0.2423
11.3883 -0.2394
11.5027 -0.2363
11.6183 -0.2335
11.7351 -0.2305
11.8530 -0.2277
11.9722 -0.2247
12.0925 -0.2220
12.2140 -0.2190