%Computing rocket landing distances for different %launching angles and velocities angles = (pi/180)*[0: 5: 90]; velocities = 25:25:500; landMatrix = RocketLanding(angles, velocities); dist = input('Enter the disired distance:'); %find the launch that the rocket landed at the desired target. EPS = 0.5; g = 9.8; [row, col] = find((landMatrix < dist+EPS)&(landMatrix > dist-EPS)); %plot the trajectory v = velocities(col(1)); angle = angles(row(1)); ltime = 2*v*sin(angle)/g; T = [0:0.01:ltime]; dx = v.*T.*cos(angle); dy = v.*T.*sin(angle) - g.*T.*T/2; plot(dx, dy); title('Rocket Launching'); xlabel('Horizontal distance (m)'); ylabel('Vertical distance (m)');