Main Content

toRadians

Convert angles to radians

    Description

    example

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

    Examples

    collapse all

    Convert several values to radians from degrees.

    [R1,R2,R3,R4] = toRadians("degrees",45,90,135,180)
    R1 = 0.7854
    
    R2 = 1.5708
    
    R3 = 2.3562
    
    R4 = 3.1416
    

    Convert the same values to radians by specifying an array.

    A = [45 90 135 180];
    R = toRadians("degrees",A)
    R = 1×4
    
        0.7854    1.5708    2.3562    3.1416
    
    

    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 radians, 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