function initial_velocity = speed_for_angle(p, theta) g = 9.81; height_difference = p.height_final - p.height_initial; top_term = g * p.displacement^2; bottom_term = 2 * cosd(theta)^2 * (p.displacement * tand(theta) - height_difference); initial_velocity = sqrt(top_term/bottom_term); end