Solve a second order BVP with a singularity problem
1 view (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Boundary Value Problems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!