Singular Jacobian using bvp4c
조회 수: 6 (최근 30일)
이전 댓글 표시
I know similar questions have been asked, but I am wondering if there any tricks to help out here. I've tried changing variables, but the divergence just moves around...
I am trying to solve a second order equation, given in the screen shot below, and the associated code is attached:

I did not impose the condition f>=0, so maybe that is my issue? The hyperbolic tanh might also be a good initial guess, but I was relying on the Sxint = deval() to get me started. Any obvious problems? Thanks in advanced for any help!
xl = 0;
xr = 10;
[Sxint, xint] =bvp4c_mathworks_Abrikosov(xl,xr);
plot(xint,Sxint)
function [Sxint, xint] =bvp4c_mathworks_Abrikosov(xl,xr)
N = 500;
xint = linspace(xl,xr,N);
solinit = bvpinit(xint,[0 0]);
sol = bvp4c(@myode,@mybc,solinit);
Sxint = deval(sol,xint);
end
function dy = myode(r,y)
k = 1/sqrt(1.8);
dy(1,1) = y(2);
dy(2,1) = k^2*(y(1)^2-1)*y(1)+y(1)/r^2-y(2)/r;
end
function res = mybc(ya,yb)
res = [ya(1)
yb(1)-1];
end
댓글 수: 0
답변 (1개)
nick
2024년 2월 29일
Hello Marcus,
I understand that you're encountering the "Singular Jacobian using bvp4c" error while attempting to solve a boundary value problem.
Upon inspecting the code, it appears that the issue arises when the function 'myode' is called with the value of 'r' being zero, as shown:
This results in the computation of 'dy(2,1)' to be 'NaN' because it involves division of zero by zero, which leads to the error you're experiencing. To rectify this, you should either initialize 'r' with a non-zero value or adjust the formula used to compute 'dy(2,1)' to handle the case when 'r' is zero.
Hope this helps.
댓글 수: 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!