what is command for instead DEGREES(ATAN2(A2,B2)) formula in excel??

Dear all !!!
I tried to change formula from excel file to matlab function. But result didnot same as figure.
Can anyone help me to explain and fix it?
Thank you

6 Comments

E = [-0.01462;-20.5145;-0.01462];
N = [6.18e-8;-13.9457;1.22e-7];
atan2d(N,E)
ans = 3×1
179.9998 -145.7922 179.9995
Please upload your actual data in a mat file by clicking the paperclip button.
Thank you for your anwser.
I send original data.
Please check.
It seems to be related to your MATLAB version or code:
S = load('testData.mat')
S = struct with fields:
E: [22×1 double] N: [22×1 double] ans: [22×1 double]
V = atan2d(S.N,S.E);
fprintf('%3d %+23.18f %+23.18f %+23.18f\n',[1:22;S.E.';S.N.';V.'])
1 +1.534755655000000107 +1.023140523999999996 +33.689294415455421472 2 +0.628518817000000007 +0.422601643999999999 +33.915981774784171421 3 +9.953971353000000022 +6.661545993999999915 +33.791823005616059561 4 +0.723525607999999987 +0.489329610999999998 +34.070991468982818162 5 +0.942775637000000000 +0.622783332999999995 +33.448147950926838234 6 +0.584666919000000007 +0.400360743000000019 +34.402064761868423659 7 +0.219249561000000009 +0.344754380000000027 +57.545322875624691505 8 +9.478616252000000131 +71.797797529999996868 +82.479404549875809494 9 -0.073083982000000006 +0.333632437000000004 +102.355784458927232095 10 -1.403193348999999923 +2.135243731000000089 +123.311252685250636318 11 -0.694284373999999982 +0.144571408000000012 +168.237340163235700174 12 -1.527420526000000001 -1.034267362000000023 -145.896761318010931063 13 -12.043986679999999723 -8.107307045000000656 -146.053867371130621677 14 -16.962494819999999862 -11.387997280000000444 -146.124036158969630605 15 -17.116039069999999356 -11.476913189999999432 -146.156740863976864375 16 -0.014616585000000000 +0.000000068132100000 +179.999732927918557834 17 -20.514493670000000236 -13.945714969999999155 -145.792206708898618217 18 -0.014616621999999999 +0.000000121904000000 +179.999522147818737494 19 -12.891952310000000637 -8.596480636000000786 -146.304253756597518077 20 -0.511586273000000036 -0.344748329999999992 -146.024713857820046314 21 -0.496969569000000000 -0.333627351999999988 -146.125609764926224443 22 -0.935472234999999985 -0.622770849999999987 -146.347148524072082409
@galaxy - not all Q3 values are -ive it appears; looks like it's a bug related to the small size of the N argument at what looks to be the size of precision for single precision.
It would seem a bug; would have to search the bug list to see when it was reported/fixed; current releases return the expected result.
If you can't upgrade, it would seem you would have to write a user replacement that checks and corrects sign.
Hi galaxy,
exactly how, in what environment, are those values of -179... being calculated? Certainly if you import the values of E and N into Matlab, you get +179... as you should.
Thank you for your answers.
I don't know why, but I tried in Matlab ver 2019b, it had right value, 179.
Maybe I was wrong. I will detele this question, sorry for the inconvenience.

Sign in to comment.

Answers (1)

Since -179 and 179 degrees are very nearly equal, those results are actually within the tolerance of your other results. If you used the wrong sign on the "N" component this would explain it, and just keep in mind when very small number and very large numbers are used together in calculations this can lead to odd results. Also is the Excel screenshot showing any rounding, such that the calculations are using additional digits of precision that Excel is not displaying?

Products

Release

R2019b

Tags

Asked:

on 3 Jun 2022

Commented:

on 8 Jun 2022

Community Treasure Hunt

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

Start Hunting!