Solve a second order BVP with a singularity problem

1 回表示 (過去 30 日間)
Jacob Jepson
Jacob Jepson 2020 年 3 月 23 日
I am trying to use BVP4C to solve a second order nonlinear BVP. My code below includes the initial guess, boundary conditions etc. I think there is something wrong with the division by y(1) in the bvpfcn part, as without it there seems to be no problem running it. Could someone suggest a way to get round this? Even if I try the interval to be (-100,-1) there still seems to be a problem with not being able to meet the tolerance. Many thanks in advance!
xmesh = linspace(-100,0,500);
solinit = bvpinit(xmesh, @guess);
sol = bvp4c(@bvpfcn, @bcfcn, solinit);
plot(sol.x,sol.y(1,:),'k')
function dydx = bvpfcn(~,y) %The BVP problem
%dydx = zeros(2,1);
dydx = [y(2)
(y(1)-1) - y(2)*(15+y(2))/y(1)]; %I think the problem is the division by y(1) here
end
function res = bcfcn(ya,yb) %Boundary conditions
res = [ya(2)
yb(1)];
end
function g = guess(x) %Initial guess
g = [sin(x)
cos(x)];
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeBoundary Value Problems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by