error with Bvp4c - Unable to solve the collocation equations -- a singular Jacobian encountered.

4 visualizaciones (últimos 30 días)
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

Respuestas (1)

darova
darova el 13 de Abr. de 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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by