MATLAB Inverse Cosine

This tutorial will discuss finding the inverse cosine of value using the acos() and acosd() functions in MATLAB.

MATLAB Inverse Cosine

We can use the acos() and acosd() functions of Matlab to find the inverse cosine of a value. The acos() function returns the inverse cosine of a value in radians, and the acosd() function returns the inverse cosine of a value in degrees.

The acos() and acosd() function accepts inputs in real and in complex form. If the input value is real and falls within a -1 to 1 interval, the function will return values within the interval of 0 to pi.

If the input value is real and falls outside the interval of -1 to 1 and for complex values, the function will return complex values. For example, let’s find the inverse cosine of a value in radians and degrees.

See the code below.

clc
clear

radian_out = acos(0.5)
degree_out = acosd(0.5)

Output:

radian_out = 1.0472
degree_out = 60.000

In the above code, we used a 0.5 value, and we can see in the output that the result is returned both in radian and degrees. We can also find the inverse cosine of a vector containing multiple values, and the values can be real or complex.

The acos() and acosd() will return a vector containing the inverse cosine of each value present in the input vector. For example, let’s create a vector with multiple values and find the inverse cosine of each value.

See the code below.

clc
clear

values = [0 0.5 0.7 0.9]
radian_out = acos(values)
degree_out = acosd(values)

Output:

values =

         0    0.5000    0.7000    0.9000


radian_out =

    1.5708    1.0472    0.7954    0.4510


degree_out =

   90.0000   60.0000   45.5730   25.8419

Each value is returned in radians and degrees in the above output. The function’s input can be a scalar, vector, matrix, or multidimensional array of real or complex values.

Write for us
DelftStack articles are written by software geeks like you. If you also would like to contribute to DelftStack by writing paid articles, you can check the write for us page.