finding intercept point in the plot

2 vues (au cours des 30 derniers jours)
FRANCISCO CORTEZ
FRANCISCO CORTEZ le 8 Avr 2021
close all
theta = 50;
v0=200;
slope= 0.1;
vx=v0*cosd(theta); %horizontal component of velocity vector
vy=v0*sind(theta); %vertical component of velocity vector
g=9.807;
tf=2*vy/g; %total flight time
t=linspace(0,tf,150);
for r=1:length(t)
x(r)=vx*t(r); %horizontal postion
A(r)=vy*t(r)-0.5*g*t(r)^2; %vertical postion of particle
R(r)=x(r)*slope; %vertical postion of terrain
end
figure(1)
plot(x,A,'b')
hold on
plot(x,R,'m')
title('Altitude VS Range')
xlabel('Range')
ylabel('Altitude')
legend({'Range','Line of Terrain'},'Location','southwest')
grid on
hold on

Réponse acceptée

Star Strider
Star Strider le 8 Avr 2021
Try this:
theta = 50;
v0=200;
slope= 0.1;
vx=v0*cosd(theta); %horizontal component of velocity vector
vy=v0*sind(theta); %vertical component of velocity vector
g=9.807;
tf=2*vy/g; %total flight time
t=linspace(0,tf,150);
for r=1:length(t)
x(r)=vx*t(r); %horizontal postion
A(r)=vy*t(r)-0.5*g*t(r)^2; %vertical postion of particle
R(r)=x(r)*slope; %vertical postion of terrain
end
[Amax,idx] = max(A);
x_int = interp1(A(idx:end)-R(idx:end), x(idx:end), 0);
y_int = interp1(x, R, x_int);
figure(1)
plot(x,A,'b')
hold on
plot(x,R,'m')
plot(x_int, y_int, 'rs')
title('Altitude VS Range')
xlabel('Range')
ylabel('Altitude')
legend({'Range','Line of Terrain','Intercept'},'Location','southwest')
grid on
hold off
.
  16 commentaires
FRANCISCO CORTEZ
FRANCISCO CORTEZ le 13 Avr 2021
got it thank you
Star Strider
Star Strider le 13 Avr 2021
s always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (2)

FRANCISCO CORTEZ
FRANCISCO CORTEZ le 12 Avr 2021
How can i determine the initial angle of the projectile with respect to the horizontal in order to achieve maximum range

Image Analyst
Image Analyst le 22 Mai 2022
See attached demo that computes just about everything you could ever want to know about a projectile.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by