필터 지우기
필터 지우기

Calculate distance from geographics points

조회 수: 1 (최근 30일)
RAFFAELE MAGLIONE
RAFFAELE MAGLIONE 2022년 4월 25일
댓글: RAFFAELE MAGLIONE 2022년 4월 26일
Hi, I have two vectors of coordinates, latitude and longitude, of points describing the centerline of a track. I want to create a distance channel to plot some quantities (e.g. velocity) as function of this distance, how can I create a distance channel of the same numerosity of the two vectors of coordinates?

답변 (1개)

KSSV
KSSV 2022년 4월 25일
편집: KSSV 2022년 4월 25일
USe Haversine's formula:
Let (lon1,lat1) and (lon2,lat2) be your coordinates in degrees.
% Haversine formula
dlon = lon2 - lon1 ;
dlat = lat2 - lat1 ;
a = sind(dlat/2)^2 + cos(dlat1)*cosd(lat2)*sin(dlon/2)^2 ;
c = 2*asind(sqrt(a)) ;
d = 6367*c ; % distance in km
  댓글 수: 11
Bruno Luong
Bruno Luong 2022년 4월 26일
편집: Bruno Luong 2022년 4월 26일
Just wonder do you have you long / lat in degree or radian?
My code supposes long/lat in radian as you see it use cos function on them.
180/pi % ratio bewteen rad and deg
ans = 57.2958
RAFFAELE MAGLIONE
RAFFAELE MAGLIONE 2022년 4월 26일
I was working with degrees, now with radian return the exact length, thank you!

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by