Passing a known vector to BVP4C
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Boundary Value Problems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!