I have the following values that I run through the atan2 function:

`a(77:78,:)ans = -0.250000000000000 0 -0.950000000000000 -0.260000000000000 0 -0.950000000000000`

when I put the above array through the atan2 function, the first value is positive and the second is negative,

` atan2(a(77:78,2),a(77:78,3))ans = 3.141592653589793 -3.141592653589793`

If I type in each value of the second row of data by hand, the result is differnt for the atan2 function (it is positive):

` atan2(0,-0.95)ans = 3.141592653589793`

If I build a test matrix, manually inputing the values, the atan2 results are both positive.

` test = [-0.25, 0 , -0.95; -0.26, 0 , -0.95]test = -0.250000000000000 0 -0.950000000000000 -0.260000000000000 0 -0.950000000000000>> atan2(test(1,2),test(1,3))ans = 3.141592653589793>> atan2(test(2,2),test(2,3))ans = 3.141592653589793`

Question: Why are the values of atan2 function positive and negative in the first case but then both positive when I type out the values?

Aside: If done separately:

` atan2(a(77,2),a(77,3))ans = 3.141592653589793>> atan2(a(78,2),a(78,3))ans = -3.141592653589793`

Thank you

## Best Answer