Error in bvp4c
Show older comments
I have to solve the following equation using bvp4c. But I cannot understand the error in my code.
where p=1 and boundary conditions are 
Please help me to find the error in the code.
p=1;
xmesh = linspace(-1,1,5);
solinit = bvpinit(xmesh,@guess);
sol = bvp4c(@bvpfcn,@bcfcn,solinit);
plot(sol.x,sol.y,'-o');
function dydx = bvpfcn(p,x,y)
dydx = zeros(2,1);
dydx = [y(2)
(-2+8*x^2*y(1))/(p+x^2)^2];
end
function res = bcfcn(p,ya,yb)
res = [ya(1)-(1/(1+p))
yb(1)-(1/(1+p))];
end
function g = guess(x)
g = [sin(x)
cos(x)];
end
Accepted Answer
More Answers (0)
Categories
Find more on Boundary Value Problems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



