Solve a system of 3, 2nd order boundary value problems using bvp4c
19 ビュー (過去 30 日間)
古いコメントを表示
Hello, I want to solve a system of 3 boundary value equations. All three of them are 2nd order. Now I have created my dydx by converting them into 6 ODE's. Since they are huge equations (almost 30 lines) I can give you a gist of them. Baiscally its
eqn1: d2y1/dx +dy1/dx+dy2/dx+dy3/dx+y1+y2+y3+x = const1
eqn2: d2y2/dx +dy1/dx+dy2/dx+dy3/dx+y1+y2+y3+x = const2
eqn3: d2y3/dx +dy1/dx+dy2/dx+dy3/dx+y1+y2+y3+x = const3
Now to put the above equations into bvp4c I converted the above 3 set of equations into 6 set of equations in 1st order ODE's
eqn1: y(2)
eqn2: y(2)+y(4)+y(6)+y(1)+y(3)+ y(5) = const1
eqn3: y(4)
eqn4: y(2)+y(4)+y(6)+y(1)+y(3)+ y(5) = const2
eqn5: y(5)
eqn6: y(2)+y(4)+y(6)+y(1)+y(3)+ y(5) = const3
I know the boundary values of the original 3 equations. They are:
y1(0) = 0.6;
y1(20) = 0;
y2(0) = 0.3;
y2(20) = 0;
y3(0) = 0.005;
y3(20) = 0;
I have written the bcfun function like this:
function res = bcfun(ya, yb)
res = [ya(1); yb(1); ya(2); yb(2); ya(3); yb(3)];
end
And I have written the bvp4c code like this
ya(1) = 101325*0.6;
yb(1) = 0;
ya(2) = 101325*0.3;
yb(2) = 0;
ya(3) = 101325*50e-06;
yb(3) = 0;
solinit = bvpinit(linspace(0,4,5),[1 0], linspace(0,4,5),[1 0], linspace(0,4,5),[1 0]);
sol = bvp4c(@myodesubfunc, @bcfun, solinit);
xint = linspace(1e-20, 20e-6, 50)
yint = deval(sol, xint)
After running this I get an error
??? Error using ==> myodesubfunc
Too many input arguments.
Error in ==> bvparguments at 106
testODE = ode(x1,y1,odeExtras{:});
Error in ==> bvp4c at 130
[n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Error in ==> bvp at 28
sol = bvp4c(@myodesubfunc, @bcfun, solinit);
If you can help me with the syntax ( just a small part of it) that will great
Thanks, Nitin Nair
0 件のコメント
回答 (4 件)
Walter Roberson
2012 年 1 月 26 日
Since it is the myodesubfunc function that is being complained about, we need to see the code for myodesubfunc .
0 件のコメント
Walter Roberson
2012 年 1 月 26 日
You are passing more than two values to bvpinit(). There is no bvpinit() syntax defined for six parameters, so possibly anything beyond the third parameter is being ignored. The three-parameter form of bvpinit() initializes the 'parameters' field of solinit. Then in the bvp4c() call, if the 'parameters' field of solinit is defined, then your ode function must accept 3 arguments, but your ode function myodesubfunc only accepts two arguments, leading to the error about two many input arguments.
I would suspect your bvpinit() call is incorrect.
0 件のコメント
eh
2013 年 11 月 29 日
Hi I want to solve system of coupler ODEs in ode45 my boundary condition :: Some conditions are initially And others in end . can you helpe mi to enter boundary condition???
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Biotech and Pharmaceutical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!