Error using bvp4c (singular jacobian encountered)
1 次查看(过去 30 天)
显示 更早的评论
Hi, I got error while running this problem of bvp. What does this mean and how to solve this?
Error:
Error using bvp4c (line 251)
Unable to solve the collocation equations -- a singular Jacobian encountered
Here is the code:
function ex111bvp
n=1;
solinit = bvpinit(linspace(0,20,2),[0 0 0 0 -1]);
options = bvpset('Stats','on','RelTol',1e-5);
sol = bvp4c(@ex111ode,@ex111bc,solinit,options);
% The solution at the mesh points
x = sol.x;
y = sol.y;
figure
plot(x,y')
title('Example 111')
ylabel('sol')
xlabel('eta')
% --------------------------------------------------------------------------
function dydx = ex111ode(x,y,n)
n=1;
dydx = [ -2*y(3)-x*(1-n/(n+1))*y(4)
y(3)
y(2)^2-(y(4)+1)^2+(y(1)+(1-n/(n+1))*x*y(2))*y(3)-y(3)*(n-1)*(y(3)^2+y(5)^2)^((n-3)/2)*y(5)*(((y(3)^2+y(5)^2)^((n-1)/2)+y(3)^2*(y(3)^2+y(5)^2)^((n-3)/2)*(n-1))*((y(3)^2+y(5)^2)^((n-1)/2)+y(5)^2*(y(3)^2+y(5)^2)^((n-3)/2)*(n-1))-((y(3)^2+y(5)^2)^((n-1)/2)+y(5)^2*(y(3)^2+y(5)^2)^((n-3)/2)*(n-1))*(y(3)*(y(1)-x*y(2)*(1-n/(n+1)))-(y(4)+1)^2+y(2))+((y(3)^2+y(5)^2)^(3-n)*(y(3)^2+y(5)^2)^((n-3)/2)*(y(5)*(y(1)-x*y(2)*(1-n/(n+1)))-2*y(2)*(y(4)+1)))/(y(3)*y(5)*(n-1)))/(((y(3)^2+y(5)^2)^((n-1)/2)+y(3)*(n-1)*(y(3)^2+y(5)^2)^((n-3)/2)))
y(5)
-2*y(2)*(y(4)+1)+(y(1)-x*(1-n/(n+1))*y(2))*y(5)-y(5)*(n-1)*(y(3)^2+y(5)^2)^((n-3)/2)*y(3)*(y(3)*y(5)*(y(3)^2+y(5)^2)^((n-3)/2)*(n-1)*(y(3)*(y(1)-x*y(2)*(1-n/(n+1)))-(y(4)+1)^2+y(2))-((y(3)^2+y(5)^2)^((n-1)/2)+y(3)^2*(y(3)^2+y(5)^2)^((n-3)/2)*(n-1))*((y(3)^2+y(5)^2)^((n-1)/2)+y(5)*(y(3)^2+y(5)^2)^((n-1)/2)+y(5)*(y(3)^2+y(5)^2)^((n-3)/2)*(n-1))-((y(3)^2+y(5)^2)^(3-n)*(y(5)*(y(1)*x*y(2)*(1-n/(n+1)))-2*y(2)*(y(4)+1))*((y(3)^2+y(5)^2)^((n-1)/2)+y(3)*(y(3)^2+y(5)^2)^((n-3)/2)*(n-1)))/(y(3)^2*y(5)^2*(n-1)^2))/(((y(3)^2+y(5)^2)^((n-1)/2)+y(5)*(n-1)*(y(3)^2+y(5)^2)^((n-3)/2))) ];
%-------------------------------------------------------------------------
function res = ex111bc(ya,yb)
res = [ ya(1)
ya(2)
ya(4)
yb(2)
yb(4)+1];
%-------------------------------------------------------------------------
Thank you in advance.
0 个评论
回答(1 个)
Torsten
2016-1-18
Use
sol = bvp4c(@(x,y)ex111ode(x,y,n),@ex111bc,solinit,options);
as call to bvp4c.
If the problem persists, look whether dydx contains Inf or NaN values.
Best wishes
Torsten.
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!