Distances and bearings between points on an ellipsoidal-model earth
Vincenty’s solution for the distance between points on an ellipsoidal earth model is accurate to within 0.5 mm distance
We can use live examples at https://www.movable-type.co.uk/scripts/latlong-vincenty.html
You can git the Matlab Version at git@github.com:Jason-Yoo/Vincenty-solutions.git

首先将起点P1和终点P2的纬度转换为弧度记为φ1,φ2,并计算经度差:
对P1、P2点点纬度进行归化处理:
设初始条件$ \lambda_0 = \Delta L$,迭代公式:
当$\varepsilon = 10^{-12}$,迭代终止:
式中 $\alpha$ 为大椭圆航线在赤道的方位角;$\sigma$ 为起点与终点间的球面角距;$\sigma_m$ 为大椭圆航线与赤道的交点到大椭圆航线中点点球面角距。
最后分别计算距离$s$、起点和终点各自的方位角度𝜶1、𝜶2,𝜶1是起点经线按顺时针方向到大椭圆航线夹角,𝜶2是终点经线按顺时针方向到大椭圆航线夹脚;
式中:$a=6378137.0m,b≈6 356752.314245m$ 分别为WGS-84椭球的长半轴和短半轴。