Need Assistance for 'bvp4c' function
显示 更早的评论
Guys, appreciate your time for this. Below is the coding which the error always persist. I need advise so much, thanks in advance.
xlow = 0;
xhigh = 10;
solinit = bvpinit(linspace(xlow,xhigh,2000), [0 0 0 1 0]);
options = bvpset('RelTol',1e-6,'AbsTol',1e-9);
sol = bvp4c(@bvp4ode,@bvp4bc,solinit,options);
xint = linspace(xlow,xhigh);
Sxint = deval(sol,xint);
function dydx = bvp4ode (x,y)
z=10;
n=1;
pr=0.733;
dydx = [y(2);y(3);(-(z+((n+3)/4)*y(1))*y(3)+((n+1)/2)*(y(2)^2)-y(4))/(1+z*x)
;y(5);(pr*n*y(2)*y(4)-(z+((n+3)/4)*y(1)*pr)*y(5))/(1+z*x)]
z=10;
n=1;
pr=0.733;
function res = bvp4bc (ya,yb)
res = [ya(1);ya(2);ya(4)-1;yb(2);yb(4)];
plot(xint,Sxint(2,:))
Error: Undefined function or variable 'bvp4ode'.
Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
I am new to MATLAB, appreciate all the help I can get.
回答(2 个)
Walter Roberson
2016-4-13
0 个投票
Which file did you store bvp4ode in? Which file did you store bvp4bc in? Which file did you store your script in?
Torsten
2016-4-14
Try this:
function driver
xlow = 0;
xhigh = 10;
solinit = bvpinit(linspace(xlow,xhigh,2000), [0 0 0 1 0]);
options = bvpset('RelTol',1e-6,'AbsTol',1e-9);
sol = bvp4c(@bvp4ode,@bvp4bc,solinit,options);
xint = linspace(xlow,xhigh);
Sxint = deval(sol,xint);
plot(xint,Sxint(2,:))
function dydx = bvp4ode(x,y)
z=10;
n=1;
pr=0.733;
dydx = [y(2);y(3);(-(z+((n+3)/4)*y(1))*y(3)+((n+1)/2)*(y(2)^2)-y(4))/(1+z*x)
;y(5);(pr*n*y(2)*y(4)-(z+((n+3)/4)*y(1)*pr)*y(5))/(1+z*x)];
function res = bvp4bc(ya,yb)
res = [ya(1);ya(2);ya(4)-1;yb(2);yb(4)];
Best wishes
Torsten.
类别
在 帮助中心 和 File Exchange 中查找有关 Boundary Value Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!