
error with Bvp4c - Unable to solve the collocation equations -- a singular Jacobian encountered.
3 views (last 30 days)
Show older comments
I am trying to solve a second order boundary value problem using bvp4c
d^2y1/dz^2 = .2*y1
d^2y2/dz^2 = .2851*y1
y1(z=0) = .21
dy2/dz(z=0) = 0
y2(z=1) = 0
dy1/dz(z=1)=.127
my functions are
function dydz = bvpfcn(z,y) % equation to solve
dydz=[y(2)
.2*y(1)
y(4)
.2851*y(1)];
end
function res = bcfcn(ya,yb) % boundary conditions
res = [ya(1)-.21
0
yb(2)-.127
0];
end
function g = guess(z) % initial guess for y and y'
g = [-.001*z
-z
.001*z
z];
end
mesh = linspace(0,1);
solinit = bvpinit(mesh, @guess);
sol = bvp4c(@bvpfcn, @bcfcn, solinit)
Is this becuase both of my functions depend on y1?
Thank you
0 Comments
Answers (1)
darova
on 13 Apr 2020
Your boundary conditions are wrong. Try these
function res = bcfcn(ya,yb) % boundary conditions
res = [ya(1)-.21 % y1(z=0) = 0.21
ya(4)-0 % dy2(z=0) = 0
yb(3)-.127 % y2(z=1) = 0.127
yb(2)-0]; % dy1(z=1) = 0

0 Comments
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!