I am trying to solve a 4th order linear ODE with boundary conditions. using bvp4c. The code is the following:

2 views (last 30 days)
function mat(solver)
if nargin<1
solver = 'bvp4c' ;
end
bvpsolver = fcnchk(solver);
pr=4;A=0.5;B=0.5;k1=0.4;Ec=2;del=1;N=1;
w=(3*N)/(3*N+4);
solinit = bvpinit(linspace(0,1,5),[0 1 0 ]);
sol = bvpsolver(@nanoode,@nanobc,solinit);
for Bnew = infinity+1:maxinfinity
solinit = bvpxtend(sol,Bnew);
sol = bvp4c(@nanoode,@nanobc,solinit);
function dfdeta = nanoode(eta,y)
dfdeta = [
y(2)
y(3)
y(4)
(1/k1)*(y(1)^-1)*((y(2)^2)-(y(1)*y(3))-(k1*(y(3)^2))+(2*k1*y(2)*y(4)))
];
end function res1 = nanobc(y0,yinf) res1 = [y0(1)-0 y0(2)-1 yinf(2)-0 ];
end
but i get the following error
Error in ==> Walter>nanoode at 27 dfdeta = [
Error in ==> bvparguments at 116 testODE = ode(x1,y1,odeExtras{:});
Error in ==> bvp4c at 120 [n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Error in ==> Walter at 11 sol = bvpsolver(@nanoode,@nanobc,solinit);

Answers (1)

Jan
Jan on 17 Oct 2016
A line ending with "[" is no valid Matlab syntax. Append at least the continuations characters '...'. Although it is allowd to omit the continuation marks and let assume Matlab a vertical concatenation when a line break appears, better write this explicitly to be as clear as possible:
function dfdeta = nanoode(eta,y)
dfdeta = [ y(2); ...
y(3); ...
y(4); ...
(1/k1)*(y(1)^-1)*((y(2)^2)-(y(1)*y(3))-(k1*(y(3)^2))+(2*k1*y(2)*y(4)))];

Community Treasure Hunt

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

Start Hunting!