finding the distance between points
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Matt Kindig
el 30 de Abr. de 2013
Editada: Matt Kindig
el 30 de Abr. de 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.
Respuesta aceptada
Youssef Khmou
el 30 de Abr. de 2013
Editada: Youssef Khmou
el 30 de Abr. de 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 comentario
Youssef Khmou
el 30 de Abr. de 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))
......
Más respuestas (1)
Ver también
Categorías
Más información sobre ANOVA en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!