Error Using "bvp4c" - "a singular Jacobian encountered"

2 次查看(过去 30 天)
Hi,
I'm trying to run the following code, but keep running into an error:
function bvp5
xlow=0; xhigh=1;
solinit = bvpinit(linspace(xlow,xhigh,100),[1 -1]);
sol = bvp4c(@bvp5ode,@bvp5bc,solinit);
xint = linspace(xlow,xhigh);
Sxint = deval(sol,xint);
plot(xint,Sxint(1,:))
function dydx = bvp5ode(x,y)
dydx = [ y(2) (-1-y(2)/x)];
function res = bvp5bc(ya,yb)
res = [ ya(1)-1 yb(2) ];
And I get an error involving "a single Jacobian encountered". It seems to plot fine if I use:
function dydx = bvp5ode(x,y)
dydx = [ y(2) (-1-y(2))];
I attached the differential equation I'm trying to solve as a picture, where "T" is y and "r" is x in the code above.
Thanks
  1 个评论
MOSLI KARIM
MOSLI KARIM 2023-11-7
function bvp5
xlow=0.00001; xhigh=1;
solinit = bvpinit(linspace(xlow,xhigh,100),[1 -1]);
sol = bvp4c(@bvp5ode,@bvp5bc,solinit);
xint = linspace(xlow,xhigh);
Sxint = deval(sol,xint);
plot(xint,Sxint(1,:))
function dydx = bvp5ode(x,y)
dydx = [ y(2) (-1-y(2)/x)];
function res = bvp5bc(ya,yb)
res = [ ya(1)-1 yb(2) ];

请先登录,再进行评论。

回答(1 个)

Torsten
Torsten 2015-11-9
The general solution of your equation is
y(x)=c1*log(x)+c2-x^2/4
with c1, c2 to be determined from the boundary conditions.
Now you can easily see that for the boundary conditions you want to prescribe, your equation does not have a solution.
Best wishes
Torsten.

类别

Help CenterFile Exchange 中查找有关 Boundary Value Problems 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by