why does matlab distance function returns odd errors for specific doubles, how to fix?
Afficher commentaires plus anciens
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 commentaire
Chad Greene
le 21 Juin 2016
Interesting question. I am able to replicate the problem, but I don't know the cause.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Calculus dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!