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!