Matrix dimension do not agree when solving a singular bvp using bvp4c
Mostrar comentarios más antiguos
I try to solve a singular boundary value problem using bvp4c. When I run the code I get the error below:
Error using *
Inner matrix dimensions must agree.
Error in bvpsingular/odeSingular (line 108)
f = PImS*f;
Error in bvp4c>colloc_RHS (line 622)
Freg(:,i) = Fcn(xreg(i),yreg(:,i),FcnArgs{:});
Error in bvp4c (line 189)
[RHS,yp,Fmid,NF] = colloc_RHS(n,x,Y,ode,bc,npar,xyVectorized,mbcidx,nExtraArgs,ExtraArgs);
Error in effectiveness_multiple_reactions (line 27)
sol = bvp4c(@der_y,@bc,solinit,options);
I already searched on this warning but I cannot find the solution. Can anyone help me? Below is an excerpt of my code
solinit = bvpinit([linspace(0,L,10)],[cNOi 0 cH2i 0]);
S = [0 0 0 0; 0 -2 0 0; 0 0 0 0; 0 0 0 -2];
options =bvpset('SingularTerm',S);
sol = bvp4c(@der_y,@bc,solinit,options);
function der = der_y(r,c)
der(1) = c(2);
der(2) = (R1(c(3),c(1),T) + R2(c(3),c(1),T) + R3(c(3),T))./DeNO;
der(3) = c(4);
der(4) = (1.5.*R1(c(3),c(1),T) + 2.5.*R2(c(3),c(1),T) + 0.5.*R3(c(3),T))./DeH2;
end
function res=bc(cl,cr)
res(1) = cl(2);
res(2) = cr(1)-cNOi;
res(3) = cl(2);
res(4) = cr(1)-cH2i;
end
Respuesta aceptada
Más respuestas (1)
Your boundary conditions can not be handled by bvp4c:
You prescribe two times that y(2)=0 at the left boundary point and you give the contradictory condition that y(1)=cNOi and y(1)=cH2i at the right boundary point.
Best wishes
Torsten.
Categorías
Más información sobre Boundary Value Problems en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!