function bvplinshoot % BVPLINSHOOT Implementation of the linear shooting method to % solve problem 2(b) on Assignment #10. % ELB 5/11/05 a=1; b=-pi; % boundary values N=100; x=0:1/N:1; % call ode45 with default tolerance to solve each IVP: [xjunk,W1]=ode45(@ivpone,x,[1 0]'); % note xjunk=x [xjunk,W2]=ode45(@ivptwo,x,[0 1]'); u1=W1(:,1)'; u2=W2(:,1)'; c1=1; c2=(b-a*u1(end))/u2(end); u=c1*u1+c2*u2; plot(x,u,x,u1,'--',x,u2,':'), xlabel x legend('BVP solution u','soln u_1 to first IVP','soln u_2 to second IVP') function dW=ivpone(x,W) dW=[W(2); -sin(x)*W(2)+5*W(1)+x^2-2]; % w nonhomogeneous term function dW=ivptwo(x,W) dW=[W(2); -sin(x)*W(2)+5*W(1)]; % w/o nonhomogeneous term