简体   繁体   English

Octave 求解微分方程

[英]Octave to solve differential equations

How do I solve the differential equation y'+y=t with y(0)=24?我如何用 y(0)=24 求解微分方程 y'+y=t?

Do I need to defined the differential equation with a file in the form .m?我需要用 .m 格式的文件定义微分方程吗?

To solve ordinary differential equations you've got the function lsode (run lsode for help).要求解常微分方程,您可以使用 lsode 函数(运行 lsode 寻求帮助)。

f = @(y,t) t-y;
t = linspace(0,5,50)';
y=lsode(f, 24, t);
plot(t,y);
print -djpg figure-lsnode.jpg

y 与 t

dy/dt + y = t  

Multiply integrating factor e^t on both sides.在两侧乘以积分因子e^t Then,然后,

d/dt [(e^t)y] = te^t
y = t-1+ce^(-t)  

Because, y(0)=24 then c=25因为, y(0)=24那么c=25

y = t-1+25e^(-t)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM