matlab用三种方法求解二阶微分方程x''+0.2x'=0.4x=0.2u(t),u(t)是单位阶跃函数,初始状态为0
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/21 08:35:22
matlab用三种方法求解二阶微分方程x''+0.2x'=0.4x=0.2u(t),u(t)是单位阶跃函数,初始状态为0
matlab用三种方法求解二阶微分方程x''+0.2x'=0.4x=0.2u(t),u(t)是单位阶跃函数,初始状态为0
matlab用三种方法求解二阶微分方程x''+0.2x'=0.4x=0.2u(t),u(t)是单位阶跃函数,初始状态为0
x''+0.2x'-0.4x=0.2u(t), x(0)=x'(0)=0.
1.你用Laplace Transform 做吧.
L(x'')+0.2L(x')-0.4L(x)=0.2L(u(t))
(p^2)*X(p)-p*x(0)-x'(0)+0.2(p*X(p)-x(0))-0.4*X(p)=0.2/p,
(p^2+0.2*p-0.4)*X(p)=0.2/p,
X(p)=0.2/(p^3+0.2*(p^2)-0.4p)
然后,你查Laplace Transform 表即可.或者用MAtlab 求解,代码如下:
F=0.2/(s^3+0.2*s^2-0.4*s);
x(t)=ilaplace(F,s,t)
然后,x(t)的表达式就出来了.
2.令x1=x,x2=x1'=x',把原方程转化成微分方程组:
x1'=x2
x2'=0.4*x1-0.2*x2+0.2u(t),
(x1(0),x2(0))=(0,0).
根据上述一阶微分方程组编写M函数文件DyDt.m
function ydot=DyDt(t,y)
if t>0
u(t)=1
else
u(t)=0
end
ydot=[y(2);0.4*y(1)-0.2*y(2)+0.2*u(t)];
tspan=[0,30];%solution interval
y0=[0;0];
[tt,yy]=ode45(@DyDt,tspan,y0)
3.用差分法吧.
h=t/N, N是你给定的正整数,一般取20吧.ti=it/N.如果t>0
x''(ti)=(x(i+1)-2x(i)+x(i-1))/(h^2)
x'(ti)=(x(i+1)-x(i-1))/2h
x(ti)=x(i)
u(ti)=u(i)=1
然后你写出相对应的差分方程组:
(x(i+1)-2x(i)+x(i-1))/(h^2)+0.2*(x(i+1)-x(i-1))/2h-0.4*x(i)=0.2
化成矩阵式用MATLAB计算即可.