y''(t)+6y'(t)-11y(t)=sin(t) 初始条件 y(0)=1 和 y'(0)=0

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 12:25:00
y''(t)+6y'(t)-11y(t)=sin(t) 初始条件 y(0)=1 和 y'(0)=0

y''(t)+6y'(t)-11y(t)=sin(t) 初始条件 y(0)=1 和 y'(0)=0
y''(t)+6y'(t)-11y(t)=sin(t) 初始条件 y(0)=1 和 y'(0)=0

y''(t)+6y'(t)-11y(t)=sin(t) 初始条件 y(0)=1 和 y'(0)=0
四行搞定.
y=dsolve('D2y+6*Dy-11*y=sin(t)','y(0)=1,Dy(0)=0')
t=0:0.1:1
y=subs(y)
plot(t,y)
结果:
y =
exp((-3+2*5^(1/2))*t)*(19/120*5^(1/2)+31/60)+exp(-(3+2*5^(1/2))*t)*(-19/120*5^(1/2)+31/60)-1/30*cos(t)-1/15*sin(t)
t =
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000
y =
1.0000 1.0460 1.1594 1.3199 1.5205 1.7605 2.0428 2.3726 2.7565 3.2028 3.7210

一个命令就可以了
dsolve('D2y+6*Dy-11*y=sin(t)','y(0)=1,Dy(0)=0')
D2y是y''(t),Dy是y'(t)
前面一个‘’里面是方程,后面‘’是条件
结果是exp((-3+2*5^(1/2))*t)*(19/120*5^(1/2)+31/60)+exp(-(3+2*5^(1/2))*t)*(-19/120*5^(1/2)...

全部展开

一个命令就可以了
dsolve('D2y+6*Dy-11*y=sin(t)','y(0)=1,Dy(0)=0')
D2y是y''(t),Dy是y'(t)
前面一个‘’里面是方程,后面‘’是条件
结果是exp((-3+2*5^(1/2))*t)*(19/120*5^(1/2)+31/60)+exp(-(3+2*5^(1/2))*t)*(-19/120*5^(1/2)+31/60)-1/30*cos(t)-1/15*sin(t)
稍微在整理一下
dislov使用方法
Syntax
r = dsolve('eq1,eq2,...', 'cond1,cond2,...', 'v')
r = dsolve('eq1','eq2',...,'cond1','cond2',...,'v')
Descriptiond
solve('eq1,eq2,...', 'cond1,cond2,...', 'v') symbolically solves the ordinary differential equation(s) specified by eq1, eq2,... using v as the independent variable and the boundary and/or initial condition(s) specified by cond1,cond2,....

收起

数值解法如下:
function f=myfun(t,x) % 建立M函数,即微分方程
f(1)=x(2); % dy=y',x(1)=y,x(2)=y',f(1)=y',f(2)=y''
f(2)=11*x(1)-6*x(2)+sin(t); % dy'=11y(t)-6y'(t)+sin(t)
f=f(:); % 确定输出的是列向量
>> clear...

全部展开

数值解法如下:
function f=myfun(t,x) % 建立M函数,即微分方程
f(1)=x(2); % dy=y',x(1)=y,x(2)=y',f(1)=y',f(2)=y''
f(2)=11*x(1)-6*x(2)+sin(t); % dy'=11y(t)-6y'(t)+sin(t)
f=f(:); % 确定输出的是列向量
>> clear;x0=[1,0];
>> [t,x]=ode45(@myfun,[0,10],x0);% ode45(odefun,tspan,x0)是常用的求解微分方程的指令,采用的是变步长四、五阶龙格库塔法,odefun表示微分方程即myfun,tspan表示自变量t的初值和终值,即[0,10],x0表示初值向量,即x0=(1,0)
>> plot(t,x(:,1)),grid;%画出方程解的图像
原解求法如下
>> f=dsolve('D2y+6*Dy-11*y=sin(t)','y(0)=1,Dy(0)=0') % D2y是y''(t),Dy是y'(t)
得到的解是
f =
exp((-3+2*5^(1/2))*t)*(19/120*5^(1/2)+31/60)+exp(-(3+2*5^(1/2))*t)*(-19/120*5^(1/2)+31/60)-1/30*cos(t)-1/15*sin(t)

收起

查看matlab中符号运算