Passing a known vector to BVP4C

2 vues (au cours des 30 derniers jours)
Jacob Jepson
Jacob Jepson le 2 Mar 2020
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.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by