Solve differential equations with bvp4c
이전 댓글 표시
I would like to solve 3 differential equations with bvp4c, but I kept getting error messages as:
Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Error in BPM_ode_Dec1417 (line 39)
sol=bvp4c(@odefun,@odebc,solinit,options);
Here's what I wrote:
solinit=bvpinit(linspace(0,LA,1000),[E_A U_A C3A]);
options=bvpset('RelTol',1e-3,'AbsTol',[1e-6 1e-6 1e-6]);
sol=bvp4c(@odefun,@odebc,solinit,options);
The function file is:
function [dydx]=odefun(y)
global F R T Z1 Z2 Z3 Z4 C1A C2A i U_A FixedCharge D3 e D4
C1=C1A.*exp(-Z1.*F/R/T.*(y(2)-U_A));
C2=C2A.*exp(-Z2.*F/R/T.*(y(2)-U_A));
dydx(1)=F/e*(C1-C2+10^(-8)/y(3)-y(3)+FixedCharge);
dydx(2)=-y(1);
J4=-D4*(-10^(-8)/y(3)^2*dydx(3)+Z4*F/R/T*10^(-8)/y(3)*dydx(2));
dydx(3)=-((i/F-Z4*J4)/Z3/D3)-Z3*F/R/T*y(3)*dydx(2);
end
The boundary condition is:
global C3A U_A E_A
res(1)=ya(1) - E_A;
res(2)=ya(2) - U_A;
res(3)=ya(3) - C3A;
end
I could not find the problem causing the error message here. Please help me out. Thank you very very very much!
댓글 수: 7
Torsten
2017년 12월 18일
If all boundary conditions are given at x=0, you should use ODE45 instead of BVP4C.
Best wishes
Torsten.
Luka
2017년 12월 18일
Torsten
2017년 12월 18일
How can you get an error message concerning "bvp4c" if you use "ode45" ?
Best wishes
Torsten.
Luka
2017년 12월 18일
Luka
2017년 12월 18일
Torsten
2017년 12월 18일
Please insert the complete code you are using.
Best wishes
Torsten.
Luka
2017년 12월 18일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!