How to Compute Cartesian to Polar If the ThetaZeroLocation on Top ?

조회 수: 2 (최근 30일)
Hello, like the title of this question, i need to compute a Cartesian Points to Polar Point if the ThetaZeroLocation is on top.
Im using the code :
r = sqrt(x^2+y^2) %for rho
t = atan(y/x) %for theta
even im using this code :
t = atan2(y/x)
and
[theta,rho] = cart2pol(x,y)
the answer is still wrong. The value on rho or r is right ( but its has little different ) but the value on t or theta is wrong.
for example the data is
x = -0.00781250;
y = -9.593750000000000
so the real answer is
r = 9.605468750000000
t = 1.801263427734375e+02 % == 180.126
but i get this if im using the first code
r = 9.5938
t = 1.5700
and with the cart2pol
rho = 9.5938
theta = -1.5716
i get this data pair each other so i know the real value.
The polar graphic that i use is like this :
as you can see the zero theta location is on top and its clockwise. so how do i can compute it ?
NB : im sorry if my english is bad

채택된 답변

Matt J
Matt J 2021년 5월 7일
편집: Matt J 2021년 5월 7일
x = -0.00781250;
y = -9.593750000000000;
t = 90-atan2d(y,x) %for theta
t = 180.0467
  댓글 수: 3
Matt J
Matt J 2021년 5월 8일
t = -89.7730 and t = 270.241699218750 differ by 360 degrees. In other words, they are the same angle.
Zaidan Adenin Said
Zaidan Adenin Said 2021년 5월 9일
Oh i see. Thats right. Thanks a lot for the code Mr. Matt

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by