User defined distance function
이전 댓글 표시
I'm try to calculate spherical distance between two points.
The formula is
D=R*arccos[cos(b1)*cos(b2)*cos(a1-a2)+sin(b1)*sin(b2)]
and two points' latitude is b1,b2 and its longitude is a1,a2.
I would use pdist calculate many points,but i not very well understood it. It's someone help me? Thanks a lot!
답변 (1개)
Walter Roberson
2018년 5월 8일
R = 6371000 %meters
distfcn = @(p1, p1) R * acos(cos(p1(1))*cos(p2(1))*cos(p1(2)-p2(2)) + sin(p1(1))*sin(p2(1)));
latlong = [lagitudes(:), longitudes(:)];
distances = pdist(latlong, distfcn);
댓글 수: 1
zicheng li
2018년 5월 9일
편집: zicheng li
2018년 5월 9일
카테고리
도움말 센터 및 File Exchange에서 Classification Learner App에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!