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.

Antworten (2)

Walter Roberson
Walter Roberson am 13 Apr. 2016

0 Stimmen

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

1 Kommentar

Justin Quek
Justin Quek am 13 Apr. 2016
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.

Melden Sie sich an, um zu kommentieren.

Torsten
Torsten am 14 Apr. 2016

0 Stimmen

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 Kommentare

Justin Quek
Justin Quek am 14 Apr. 2016
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!
Walter Roberson
Walter Roberson am 14 Apr. 2016
Store all of that in driver.m

Melden Sie sich an, um zu kommentieren.

Tags

Gefragt:

am 13 Apr. 2016

Kommentiert:

am 14 Apr. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by