Solve a second order BVP with a singularity problem
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Boundary Value Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!