why does matlab distance function returns odd errors for specific doubles, how to fix?
显示 更早的评论
Matlab distance function found here: /usr/local/apps/matlab-2013a/toolbox/map/map/distance.m generates an error when I give it certain values.
one example is that it would not work for these
[hex2num('bff302fba03a0023'),hex2num('4003ff6217b27e6b'),hex2num('3ff302fba03a0023'),hex2num('bfe48a64f246bab5')]
ans =
-1.1882 2.4997 1.1882 -0.6419
when plugged in as so:
distance(hex2num('bff302fba03a0023'),hex2num('4003ff6217b27e6b'),hex2num('3ff302fba03a0023'),hex2num('bfe48a64f246bab5'),'radians')
I get this error:
Error using atan2 Inputs must be real.
Error in distance>greatcircledist (line 160) rng = r * 2 * atan2(sqrt(a),sqrt(1 - a));
Error in distance (line 101) rng = greatcircledist(lat1, lon1, lat2, lon2, ellipsoid(1));
however rounding the values to
distance(-1.1882 , 2.4997 , 1.1882 , -0.6419,'radians')
works fine and returns 3.1416
1 个评论
Chad Greene
2016-6-21
Interesting question. I am able to replicate the problem, but I don't know the cause.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!