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.

Answers (2)

Which file did you store bvp4ode in? Which file did you store bvp4bc in? Which file did you store your script in?

1 Comment

Hi Walter, Thanks for your reply. I am new to MATLAB so I am not sure which file did I store it. Would you mind to give me some advise? Also, does the storing method giving me the error? Please enlighten. Thanks.

Sign in to comment.

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.

3 Comments

Hi Torsten, The error still persist as "Error: Function definitions are not permitted in this context." Please assist me as I am new to MATLAB. Thanks for your reply and advise!
Store all of that in driver.m

Sign in to comment.

Tags

Asked:

on 13 Apr 2016

Commented:

on 14 Apr 2016

Community Treasure Hunt

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

Start Hunting!