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

조회 수: 3 (최근 30일)
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

답변 (1개)

darova
darova 2020년 4월 13일
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

카테고리

Help CenterFile Exchange에서 Boundary Value Problems에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by