How do I solve this bvp4c error ?

2 views (last 30 days)
So, the error I am getting is : "Unable to solve the collocation equations -- a singular Jacobian encountered" When ever I change "K" value of the global variable to 0, and also the error : Error in Comparison sol = bvp4c(@rhs_bvp, @bc_bvp, init);
The highest order is 2 in the equation :
And the equation is subjected to the boundary value: y = 0 at x = -1 and y = 1 at x = 1
global G m M Da k e1 e2 Uhs beta n gamma
M = 2; m = 0.1; Da = 0.1; Uhs = 1; e1 = 2; e2 = 2; G = 1; k = 0; beta = 0.025;
n = 0; gamma = 0.25;
init = bvpinit (linspace(-1,1),[1 0]);
sol = bvp4c(@rhs_bvp, @bc_bvp, init);
yplot =sol.y(1,:);
xplot =sol.x;
plot(xplot,yplot)
function rhs = rhs_bvp(x,y)
global G m M Da k e1 e2 Uhs gamma n
vel = (((M^2/(1+(m^2))+(1/Da))*y(1)) - G - ((k^2)*Uhs)*((( (e1+e2)/(2*cosh(k))*cosh(k*x) ) - (((e1- e2)/(2*sinh(k)))*sinh(k*x)))))/((1-n)+((sqrt(2))*n*gamma*y(2)));
rhs = [ y(2)
vel
];
end
function bc = bc_bvp(yl,yr)
bc = [yl(1)
yr(1)-1
];
end
Could the error be in the initial value of the problem ?

Accepted Answer

Alan Stevens
Alan Stevens on 17 Oct 2020
You have a division by sinh(k)
.../(2*sinh(k)))...
Since k is zero, sinh(k) is zero and the resuting expression for vel is NaN.
  1 Comment
Aryaman Patel
Aryaman Patel on 18 Oct 2020
Edited: Aryaman Patel on 18 Oct 2020
Oh I see ! Thanks for pointing it out !

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!