% Shooting method for a simple boundary value problem % Problem statement: % y''(t) = -sin(y(t)) (Nonlinear pendulum) % y(0) = 0, y(2) = pi/2 % Find y(t) yp0 = fminsearch('bvp_shooting_error', 1); y0 = 0; [t,y] = ode45('bvp_shooting_rhs', [0 2], [y0 yp0]); plot(t, y(:,1), 'b-')