Wrong solution of a tangent using a matrix.
Ältere Kommentare anzeigen
Hello!
For my studies I have to calculate the tangent of a full matrix (512x512) where the values are angles in radians,(getted by the function atan2).
The results are so high and that made me think there was sth wrong. So I did a test.
In the Command window I wrote l=atan2(0.3,0) which value is 1.5708. Then I calculated the tan(l) getting 1.6331 e+16.
That was obviously wrong because the real value is -272241.8.
After that, in the same Comand Window I wrote tan(1.5807) getting in this case the correct solution.
Why is this wrong? There is sth wrong using matrix or arrays?? Or is sth with atan2 and tan?
Thanks a lot in advance,
Celia
Antworten (1)
Azzi Abdelmalek
am 27 Sep. 2013
1 Stimme
tan(1.5807)=-100.9693
How did you get -272241.8 ?
4 Kommentare
Azzi Abdelmalek
am 27 Sep. 2013
Celia commented
I wanted to say tan(1.5708), sorry!
Azzi Abdelmalek
am 27 Sep. 2013
Bearbeitet: Azzi Abdelmalek
am 27 Sep. 2013
I=atan2(0.3,0) % correspond to the angle of 0+0.3*j which is pi/2. It obvious that tan(pi/2)=inf. I do not understand why are you expecting another result
Azzi Abdelmalek
am 27 Sep. 2013
I=atan2(0.3,0) %the result displayed is 1.5708, this is not the complete result
To understand type
format long
I=atan2(0.3,0) % The more precise result
Celia
am 30 Sep. 2013
Kategorien
Mehr zu Pulse and Transition Metrics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!