distance function sometimes giving atan2 error, why is this?

조회 수: 13 (최근 30일)
Pedro Ribeiro
Pedro Ribeiro 2016년 6월 17일
댓글: Steven Lord 2016년 6월 22일
Using matlab2013 I am very confused by this error. For the same input's it'll sometimes give me an error and sometimes not. example: I have two vectors, lets call them A and B.
This gives me an error:
distance(A(96562),B(96562),A,B,'radians');
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));
The values are such:
A(96562)
ans =
-0.360233642765199
B(96562)
ans =
2.132182023972182
Here's the odd thing, plugging in the numbers does not give me an error.
distance(-0.360233642765199,2.132182023972182
,A,B,'radians');
This works fine!
The following does not
distance(A(96562),2.132182023972182
,A,B,'radians');
but now the following does?
distance(-0.360233642765199,B(96562)
,A,B,'radians');
can someone help me understand what is happening or how to figure this out? thanks!
  댓글 수: 6
Roger Stafford
Roger Stafford 2016년 6월 21일
It should be pointed out that this current question was asked by Pedro four days ago while the question you answered and which was accepted, Steven, was asked only nine hours ago. By that time the question had become more precise and he had narrowed things down to a single set of four numbers given in their IEEE hex form. It is a natural way to proceed and in my opinon does not involve unnecessary repetition of questioning.
Steven Lord
Steven Lord 2016년 6월 22일
Fair enough. My comment was intended more as an FYI that the cause of this problem has been identified elsewhere and so we don't need to continue investigating here.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by