Code covered by the BSD License  

Highlights from
atan2(0..360)

1.0

1.0 | 1 rating Rate this file 23 Downloads (last 30 days) File Size: 1.26 KB File ID: #39369

atan2(0..360)

by

 

Function calculates the arc tangent of y/x and places the result in range of [0..360]

| Watch this File

File Information
Description

Function calculates the arc tangent of y/x and places the result in range of [0..360].
To find similar examples and resources please visit www.smallsats.org

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
12 Dec 2012 Michael Völker

Where MATLAB's atan2d() is already present, only a single line is required to make the result [0...360]:

ang = mod( atan2d(y,x), 360 );

If atan2d() is not present but atan2() is, it is sufficient to use

ang = mod( atan2(y,x) .* 180./pi, 360 );

And if somehow neither atan2() nor atan2d() were present and they had to be implemented manually, I would expect them to behave like the original functions.

The most important lack of function is the inability to work on arrays.

11 Dec 2012 Richard Zapor

atan2d exists in R2012B and gives 0:180 and 0:-180.
Thus to get [0:360) is two lines
ang=atan2d(y,x);
if ang<0,ang=ang+360;end

Contact us