필터 지우기
필터 지우기

finding the distance between points

조회 수: 4 (최근 30일)
E
E 2013년 4월 29일
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
Matt Kindig
Matt Kindig 2013년 4월 30일
편집: Matt Kindig 2013년 4월 30일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Youssef  Khmou
Youssef Khmou 2013년 4월 30일
편집: Youssef Khmou 2013년 4월 30일
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
Youssef  Khmou
Youssef Khmou 2013년 4월 30일
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))
......

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

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

카테고리

Help CenterFile Exchange에서 Automotive에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by