How do I make a code for projectile motion having initial velocity and angle as an output and final distance as an input

6 visualizaciones (últimos 30 días)
Rafay el 18 de Jun. de 2023
Respondida: Lakshya el 18 de Jun. de 2023
input Max distance
ouput optimum angle and initial velocity
0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Respuestas (1)

Lakshya el 18 de Jun. de 2023
Hi,
If the input is final distance and according to you it is the Max distance (assuming you are talking about max distance that can be covered ) then we can directly say that the projection angle is 45 degrees ( using basic physics ) and from there we can easily calculate the intial velocity using the below code
function [initial_velocity, launch_angle] = projectileMotion(max_distance)
gravity = 9.81;
initial_height = 0; % Assume the projectile starts from the ground level
launch_angle = 45;
% Convert launch angle to radians
% Calculate the initial velocity required to reach the max distance
initial_velocity = sqrt((max_distance * gravity) / sin(2 * launch_angle_rad));
end
Hope this helps
0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Categorías

Más información sobre Physics en Help Center y File Exchange.

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by