finding the distance between points

2 vues (au cours des 30 derniers jours)
E
E le 29 Avr 2013
Hi! I'm studying for finals and I'm trying to rework a test problem. It's stumped me and I could use the help!
This is the problem:
Consider two airplanes that launch at the same moment and fly in the first quad of a 2-D space. Airplane A always travels at 800 km/h along a direction that makes a 20 degree angle with the x axis and originates at the coordinate origin. Airplane B always travels at 950 km/h in a direction that makes a 70 degree angle with the x axis and originates at 1000km in the x direction and 2000 km in the y direction. Make a function file that returns the distance between the two planes at a given time. Test your function at t=0,1, and 2 hrs.
I think I need to use either the norm function or the sqrt (x^2 + y^2) to find the distance but I'm kind of confused how to bring in the speed and what not into the equation. PLEASE HELP!
  1 commentaire
Matt Kindig
Matt Kindig le 30 Avr 2013
Modifié(e) : Matt Kindig le 30 Avr 2013
Write down (on paper) the equations for X and Y for each plane first. Hint:
X(t) = X0 + Vx*t %x position at time t, velocity-x component
You should then be able to figure out how to calculate the distance from there. The sqrt(x^2+y^2) thing you had will help.

Connectez-vous pour commenter.

Réponse acceptée

Youssef  Khmou
Youssef Khmou le 30 Avr 2013
Modifié(e) : Youssef Khmou le 30 Avr 2013
hi,
the Dynamic 2D position is defined as :
X(t)=V*cos(theta)*t+X0 & Y(t)=V*sin(theta)*t+Y0 .
Try this version :
theta_a=20*pi/180;
theta_b=70*pi/180;
Va=800; % Km/h
Vb=950; % Km/h
x0a=0;
y0a=0;
x0b=1000;
y0b=2000;
% Time simulation
T=0:0.5:10; % 10 hours, we measure the distance every 30 minutes
% first airplane
Xa=Va*cos(theta_a)*T+x0a;
Ya=Va*sin(theta_a)*T+y0a;
Xb=Vb*cos(theta_b)*T+x0b;
Yb=Vb*sin(theta_b)*T+y0b;
for t=1:length(T)
D(t)=sqrt((Xa(t)-Xb(t)).^2+(Ya(t)-Yb(t)).^2);
end
figure, plot(T,D), xlabel(' Time in Hours'), ylabel(' Distance /KM')
title(' Distance between two airplanes a and b '), grid on
Try now to make it as function
  1 commentaire
Youssef  Khmou
Youssef Khmou le 30 Avr 2013
so the function take t as input
Y=Yourfunction(t)
% Constantes
compute X(t) and Y(t)
compute the distance D(X(t),Y(t))
......

Connectez-vous pour commenter.

Plus de réponses (1)

E
E le 30 Avr 2013
Thank You! That made perfect sense. I knew it was a simple problem, I just couldn't remember how to solve it!

Community Treasure Hunt

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

Start Hunting!

Translated by