% Numerical Mathematics and Computing, Fifth Edition % Ward Cheney & David Kincaid % Brooks/Cole Publ. Co. % (c) 2003 % % file: bvp.m % % two-point boundary-value problem example % solinit = bvpinit(linspace(1,2,5), [0 1]); soln = bvp4c(@bvpfcn, @bvpbc, solinit) x = linspace(1,2,12) y = deval(soln,x) plot(x, y(1,:)) title('BVP problem solution') xlabel('x') ylabel('Solution y') x = linspace(1,2,12) yy = exp(x) - 3*cos(x) plot(x, yy(:)) title('BVP problem true solution') xlabel('x') ylabel('Solution exp(x) - 3cos(x)')