Main Content

fromDegrees

Convert angles from degrees

    Description

    [A1,...,An] = fromDegrees(toUnits,D1,...,Dn) converts the angles specified by D1,...,Dn from degrees to the units specified by toUnits. This function is useful for converting angles from degrees when you do not know the output units until run-time.

    example

    Examples

    collapse all

    Convert several values from degrees to radians.

    [A1,A2,A3,A4] = fromDegrees("radians",45,90,135,180)
    A1 = 
    0.7854
    
    A2 = 
    1.5708
    
    A3 = 
    2.3562
    
    A4 = 
    3.1416
    

    Convert the same values from degrees by specifying an array.

    D = [45 90 135 180];
    A = fromDegrees("radians",D)
    A = 1×4
    
        0.7854    1.5708    2.3562    3.1416
    
    

    Input Arguments

    collapse all

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

    Data Types: char | string

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

    Output Arguments

    collapse all

    Angles in degrees or radians, returned as the same number of numeric arrays as in D1,...,Dn. The size of each output array matches the size of the corresponding input array.

    Version History

    Introduced in R2007b

    See Also

    Functions