% script to bracket a solutioon to the projectileKin.m problem % HW1, PHYS220 Spring 2009 % givens (from problem statement) target = 100; vo = 50; % some constants & starting values tol = 1; % we'll allow a miss of up to this amount theta = 45; % start at a neutral angle (max range) stepTheta = 20; % coarse starting search stepDiv = 2; % cut step in half on each bracket % initial range [yMax,range,tof] = projectileKin(vo,theta); % for display purposes disp(' ') disp('theta (deg) range (m) Dtheta (deg)') disp([theta range stepTheta]) % search over angles, cut steps in half every time we pass target, display % each step in the bracketing operation while abs(target-range) > tol theta = theta + stepTheta; [yMax,range,tof] = projectileKin(vo,theta); disp([theta range stepTheta]) if sign(target-range) == sign(stepTheta) stepTheta = -stepTheta/stepDiv; end end return