% shoot Script solves a linear 2-point boundary value % problem by the simple shooting method. % Requires besselde.m % Boundary conditions a = 1; b = 6; ya = 1; yb = 0; % Fundamental solution tspan = [a b]; options = odeset('RelTol',1e-6); Y10 = [1;0]; [t1,Y1] = ode45('besselde',tspan,Y10,options); Y20 = [0;1]; [t2,Y2] = ode45('besselde',tspan,Y20,options); % Get solutions at x=6, calculate C2, then y. n1 = length(t1); Y1fin = Y1(n1,1); n2 = length(t2); Y2fin = Y2(n2,1); C2 = -Y1fin/Y2fin; disp(sprintf('C2 = %12.6e',C2)) y0 = [1;C2]; [t,y] = ode45('besselde',tspan,y0,options); plot(t,y(:,1)) xlabel('x'), ylabel('y') title('Solution of Bessel DE of order 1/2, y(1)=1, y(6)=0.')