Sunday, April 14, 2013
Calculate distance between two lat long points on the Earth – Matlab
You can calculate the distance in Kilometers between two points on the Earth. It can be calculated with either Native functions of Matlab or with your own code using the spherical law of cosines.
Lets say, C is coordinate vector containing Latitudes and Longitudes of both points in degrees.
C=[ lat1, lon1, lat2, lon2]
Using native Matlab function:
distanceKM=deg2km(distance(C(1),C(2),C(3),C(4)))
Using the mathematical formula of spherical law of cosines. (The Earth’s radius is assumed to be 6778km)
distanceKM=6378.*deg2rad(acosd(sind(C(1)).*sind(C(3))+cosd(C(1)).*cosd(C(3)).*cosd(C(2)-C(4))))
There might be slight difference between the distances calculated using both formulas.
The distance is in KM, you may convert to different unit using simple conversions.
Posted by
vicky
at
4:32 AM
Subscribe to:
Post Comments (Atom)
Popular
- Chanakya TV serial, online on youtube, Vol 1-8, All episodes 1-47
- Unbelievable invention of Bheema's skeleton or Bhima's son Gadotkach like skeleton found: A hoax mail
- How to add or endorse Spouse/ Husband /Wife name of the passport
- SBI transaction on 30-Nov-0019 for INTERNET BANKING, what is this for?
- Indian citizens resident abroad, How to register at nearest Indian mission/ post/ embassy/ consulate Milan
No comments:
Post a Comment