Main Content

toDegrees

Convert angles to degrees

    Description

    example

    [D1,...,Dn] = toDegrees(fromUnits,A1,...,An) converts the angles specified by A1,...,An from the units specified by fromUnits to degrees. This function is useful for getting angles in degrees when you do not know the input units until run-time.

    Examples

    collapse all

    Convert several values to degrees from radians.

    [D1,D2,D3,D4] = toDegrees("radians",pi/2,pi,3*pi/2,2*pi)
    D1 = 90
    
    D2 = 180
    
    D3 = 270
    
    D4 = 360
    

    Convert the same values to degrees by specifying an array.

    A = [pi/2 pi 3*pi/2 2*pi];
    D = toDegrees("radians",A)
    D = 1×4
    
        90   180   270   360
    
    

    Input Arguments

    collapse all

    Input unit, specified as "degrees" or "radians". You can also specify abbreviations such as "deg" and "rad".

    Data Types: char | string

    Angles in degrees or radians, specified as one or more numeric arrays.

    Output Arguments

    collapse all

    Angles in degrees, returned as the same number of numeric arrays as in A1,...,An. The size of each output array matches the size of the corresponding input array.

    Version History

    Introduced in R2007b

    See Also

    Functions