Solve first order BVP on MATLAB

848 Views Asked by At

I try to solve this equation on MATLAB $$y^\prime(x)=x+y^2(x)\quad\forall x\in(0,0.9),\quad y(0)=1, y(0.9)=32.725$$ I write two function on matlab, on myODE.m file, i write

function result = myODE(x,y)
    result = x + (y(1)).^2;
end

and on myBVP.m file i insert this lines

function result = myBVP(ya, yb)
    result(1) = ya(1)-1;
    result(2) = yb(1)-32.725;
end

Then i initialize solver with this command

solinit = bvpinit(linspace(0,.9,5),[0;0]);

And at end i try to solve with bvp4c solver on MATLAB:

sol = bvp4c(@myODE,@myBVP,solinit);

But MATLAB get me this error:

Error using bvparguments (line 109)
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT):
  The derivative function ODEFUN should return a column vector of length 2.

Error in bvp4c (line 130)
[n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...

Any suggestion to correct my code or solve this on true manner?