first order differential equation

4 次查看(过去 30 天)
ikhlas
ikhlas 2022-12-17
回答: Star Strider 2022-12-17
how can we solve this differential equation numerically in matlab
2xy(dy/dx)+(1+x)y^2=e^x ?

回答(1 个)

Star Strider
Star Strider 2022-12-17
One approach —
syms y(x) x Y
Dy = diff(y);
Eqn = 2*x*y*Dy+(1+x)*y^2 == exp(x);
[VF,Subs] = odeToVectorField(Eqn)
VF = 
Subs = 
odefcn = matlabFunction(VF, 'Vars',{x,Y})
odefcn = function_handle with value:
@(x,Y)[((-exp(x)+Y(1).^2+x.*Y(1).^2).*(-1.0./2.0))./(x.*Y(1))]
Then, use ‘odefcn’ in the differential equation solver (perhaps ode45) of your choice.
.

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by