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

4 ビュー (過去 30 日間)
Andrew Knight
Andrew Knight 2020 年 4 月 13 日
回答済み: darova 2020 年 4 月 13 日
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 Center および File ExchangeBoundary Value Problems についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by