Passing a known vector to BVP4C

조회 수: 2 (최근 30일)
Jacob Jepson
Jacob Jepson 2020년 3월 2일
Hi All,
I wish to solve the second order BVP (which has been turned in to a system of two first order ODEs in the code):
for the function c (where K_c,s and Diff are all constants) and where n is a known vector. I am having trouble passing the vector n to BVP4C (I think).. The following is my code
function ConcBVP = CellConcBVP(space_steps,n,s,c_bound,Diff,K_c)
xmesh = linspace(0,1,space_steps);
solinit = bvpinit(xmesh, @guess);
sol = bvp4c(@(x,y)bvpfcn(x,y,n,K_c,Diff,s), @(ya,yb)bcfcn(ya,yb,c_bound), solinit);
ConcBVP = sol.x;
function dydx = bvpfcn(y,n,K_c,Diff,s)
dydx = [y(2)
-K_c*s^2*y(1)*n/Diff];
end
function res = bcfcn(ya,yb,c_bound)
res = [ya(2)
yb(1) - c_bound];
end
function g = guess(x)
g = [sin(x)
cos(x)];
end
when I run this I get the error:
Error using bvparguments (line 108)
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT):
The derivative function ODEFUN should return a column vector of length 2.

답변 (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