0% found this document useful (0 votes)
40 views35 pages

Trigonometry For Matlab

This document describes trigonometric functions in MATLAB including sine, cosine, tangent and their inverses. It provides the syntax and examples of using these functions on real and complex numbers and for converting between radians and degrees.

Uploaded by

yacob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views35 pages

Trigonometry For Matlab

This document describes trigonometric functions in MATLAB including sine, cosine, tangent and their inverses. It provides the syntax and examples of using these functions on real and complex numbers and for converting between radians and degrees.

Uploaded by

yacob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 35

Trigonometry

The trigonometric functions in MATLAB calculate standard trigonometric values in radians or


degrees and inverse variants of each function. You can use the rad2deg and deg2rad functions to
convert between radians and degrees, or functions like cart2pol to convert between coordinate
systems.
Functions

Sine

sin Sine of argument in radians

sind Sine of argument in degrees

sinpi Compute sin(X*pi) accurately

asin Inverse sine in radians

asind Inverse sine in degrees


Cosine

cos Cosine of argument in radians

cosd Cosine of argument in degrees

cospi Compute cos(X*pi) accurately

acos Inverse cosine in radians

acosd Inverse cosine in degrees


Tangent

tan Tangent of argument in radians

tand Tangent of argument in degrees

atan Inverse tangent in radians

atand Inverse tangent in degrees

atan2 Four-quadrant inverse tangent

atan2d Four-quadrant inverse tangent in degrees


Cosecant

csc Cosecant of input angle in radians

cscd Cosecant of argument in degrees

acsc Inverse cosecant in radians

acscd Inverse cosecant in degrees


Secant

sec Secant of angle in radians

secd Secant of argument in degrees

asec Inverse secant in radians

asecd Inverse secant in degrees


Cotangent

cot Cotangent of angle in radians

cotd Cotangent of argument in degrees

acot Inverse cotangent in radians

acotd Inverse cotangent in degrees


Conversions

Degrees/Radians Conversion

deg2rad Convert angle from degrees to radians

rad2deg Convert angle from radians to degrees


Coordinate Conversion

cart2pol Transform Cartesian coordinates to polar or cylindrical

cart2sph Transform Cartesian coordinates to spherical

pol2cart Transform polar or cylindrical coordinates to Cartesian

sph2cart Transform spherical coordinates to Cartesian


1. sin
Sine of argument in radians
Syntax

Y = sin(X)
Description

Y = sin(X) returns the sine of the elements of X. The sin function operates element-wise on
arrays. The function accepts both real and complex inputs.
 For real values of X, sin(X) returns real values in the interval [-1, 1].
 For complex values of X, sin(X) returns complex values.
Plot Sine Function
Example: Plot the sine function over the domain −π≤x≤π.
x = -pi:0.01:pi;
plot(x,sin(x)), grid on
Sine of Vector of Complex Angles

Example: Calculate the sine of the complex angles in vector x.


x = [-i pi+i*pi/2 -1+i*4];
y = sin(x)
y = 1×3 complex
0.0000 - 1.1752i 0.0000 - 2.3013i -22.9791 +14.7448i
sind
Sine of argument in degrees
Syntax

Y = sind(X)
Description

Y = sind(X) returns the sine of the elements in X, which are expressed in degrees.
Sine of 180 Degrees Compared to Sine of π Radians

Example:
sind(180)
ans = 0
sin(pi)
ans = 1.2246e-16
Sine of Vector of Complex Angles, Specified in Degrees

Example:
z = [90+i 15+2i 10+3i];
y = sind(z)
y = 1×3 complex
1.0002 + 0.0000i 0.2590 + 0.0337i 0.1739 + 0.0516i
sinpi
Compute sin(X*pi) accurately
Syntax

Y = sinpi(X)
Description

Y = sinpi(X) computes sin(X*pi) without explicitly computing X*pi. This calculation is more
accurate than sin(X*pi) because the floating-point value of pi is an approximation of π. In
particular:
 For integers, sinpi(n) is exactly zero.
 For odd integers, sinpi(n/2) is +1 or -1.
Calculate Sine of Multiples of π

Example: Compare the accuracy of sinpi(X) vs. sin(X*pi).


Create a vector of values.
X = [0 1/2 1 3/2 2];
Calculate the sine of X*pi using the normal sin function.
Y = sin(X*pi)
Y = 1×5
0 1.0000 0.0000 -1.0000 -0.0000
The results contain small numerical errors due to the fact that pi is a floating-point
approximation of the true value of π. For instance, Y(3) is not exactly zero even though sin(π)=0.
Y(3)
ans = 1.2246e-16
Use sinpi to calculate the same values. In this case, the results are exact.
Z = sinpi(X)
Z = 1×5
0 1 0 -1 0
Z(3)
ans = 0
asin
Inverse sine in radians
Syntax

Y = asin(X)
Description

Y = asin(X) returns the Inverse Sine (sin-1) of the elements of X in radians. The function accepts
both real and complex inputs.
 For real values of X in the interval [-1, 1], asin(X) returns values in the interval [-π/2,
π/2].
 For real values of X outside the interval [-1, 1] and for complex values
of X, asin(X) returns complex values.
Examples

Inverse Sine of Value

Example: Find the inverse sine of a value.


y = asin(1)
y = 1.5708
Inverse Sine of Vector of Complex Values

Example: Find the inverse sine of the elements of vector x. The asin function acts on x element-
wise.
x = [0.5i 1+3i -2.2+i];
y = asin(x)
y = 1×3 complex
0.0000 + 0.4812i 0.3076 + 1.8642i -1.1091 + 1.5480i
Plot Inverse Sine Function

Plot the inverse sine function over the intervals −1≤x≤1.


x = -1:.01:1;
plot(x,asin(x))
grid on
asind
Inverse sine in degrees
Syntax

Y = asind(X)
Description

Y = asind(X) returns the inverse sine (sin-1) of the elements of X in degrees. The function accepts
both real and complex inputs.
 For real values of X in the interval [-1, 1], asind(X) returns values in the interval [-90,
90].
 For real values of X outside the interval [-1, 1] and for complex values
of X, asind(X) returns complex values.
Examples

Inverse Sine of Scalar

Example: Show that the inverse sine of 1 is exactly 90°.


asind(1)
ans = 90
sind(asind([2 3]))
ans = 1×2
2 3
Graph of Inverse Sine Function

Example: Plot the inverse sine function over the domain −1≤x≤1.
x = -1:.01:1;
plot(x,asind(x))
grid on

2. Cos
Cosine of argument in radians
Syntax

Y = cos(X)
Description

Y = cos(X) returns the cosine for each element of X. The cos function operates element-wise on
arrays. The function accepts both real and complex inputs.
 For real values of X, cos(X) returns real values in the interval [-1, 1].
 For complex values of X, cos(X) returns complex values.
Examples

Plot Cosine Function

Example: Plot the cosine function over the domain −π≤x≤π.


x = -pi:0.01:pi;
plot(x,cos(x))
grid on
Cosine of Vector of Complex Angles

Example: Calculate the cosine of the complex angles in vector x.


x = [-i pi+i*pi/2 -1+i*4];
y = cos(x)
y = 1×3 complex
1.5431 + 0.0000i -2.5092 - 0.0000i 14.7547 +22.9637i
cosd
Cosine of argument in degrees
Syntax

Y = cosd(X)
Description

Y = cosd(X) returns the cosine of the elements of X, which are expressed in degrees.
Examples

Cosine of 90 Degrees Compared to Cosine of π/2 Radians

Example:
cosd(90)
ans = 0
cos(pi/2)
ans = 6.1232e-17
Cosine of Complex Angles Specified in Degrees

Example: Create an array of three complex angles and compute the cosine.
z = [180+i 45+2i 10+3i];
y = cosd(z)
y = 1×3 complex
-1.0002 + 0.0000i 0.7075 - 0.0247i 0.9862 - 0.0091i
cospi
Compute cos(X*pi) accurately
Syntax

Y = cospi(X)
Description

Y = cospi(X) computes cos(X*pi) without explicitly computing X*pi. This calculation is more
accurate than cos(X*pi) because the floating-point value of pi is an approximation of π. In
particular:
 For odd integers, cospi(n/2) is exactly zero.
 For integers, cospi(n) is +1 or -1.
Calculate Cosine of Multiples of π

Example: Compare the accuracy of cospi(X) vs. cos(X*pi).


Create a vector of values.
X = [0 1/2 1 3/2 2];
Calculate the cosine of X*pi using the normal cos function.
Y = cos(X*pi)
Y = 1×5
1.0000 0.0000 -1.0000 -0.0000 1.0000
The results contain small numerical errors due to the fact that pi is a floating-point
approximation of the true value of π. For instance, Y(2) is not exactly zero even

though cos( =0.


π2)

Y(2)
ans = 6.1232e-17
Use cospi to calculate the same values. In this case, the results are exact.
Z = cospi(X)
Z = 1×5
1 0 -1 0 1
Z(2)
ans = 0
acos
Inverse cosine in radians
Syntax

Y = acos(X)
Description

Y = acos(X) returns the Inverse Cosine (cos-1) of the elements of X in radians. The function
accepts both real and complex inputs.
 For real values of X in the interval [-1, 1], acos(X) returns values in the interval [0, π].
 For real values of X outside the interval [-1,1] and for complex values
of X, acos(X) returns complex values.
Inverse Cosine of Value

Example: Find the inverse cosine of a value.


y = acos(0)
y = 1.5708
Inverse Cosine of Vector of Complex Values

Example: Find the inverse cosine of the elements of vector x. The acos function acts
on x element-wise.
x = [0.5i 1+3i -2.2+i];
y = acos(x)
y = 1×3 complex
1.5708 - 0.4812i 1.2632 - 1.8642i 2.6799 - 1.5480i
Plot Inverse Cosine Function

Plot the inverse cosine function over the intervals −1≤x≤1.


x = -1:.01:1;
plot(x,acos(x))
grid on
acosd
Inverse cosine in degrees
Syntax

Y = acosd(X)
Description

Y = acosd(X) returns the inverse cosine (cos-1) of the elements of X in degrees. The function
accepts both real and complex inputs.
 For real values of X in the interval [-1, 1], acosd(X) returns values in the interval [0,
180].
 For values of X outside the interval [-1, 1] and for complex values of X, acosd(X) returns
complex values.
Inverse Cosine of 0

Example: Verify that inverse cosine of 0 is exactly 90.


acosd(0)
ans = 90
Round-Trip Calculation for Complex Angles

Example: Show that the inverse cosine, followed by cosine, returns the original values of X.
cosd(acosd([2 3]))
ans = 1×2
2 3
acosd([2 3]) returns two complex angles, which are then passed to the cosd function. cosd returns
the original values, 2 and 3.
3. Tan
Tangent of argument in radians
Syntax

Y = tan(X)
Description

Y = tan(X) returns the tangent of each element of X. The tan function operates element-wise on
arrays. The function accepts both real and complex inputs.
 For real values of X, tan(X) returns real values in the interval [-∞, ∞].
 For complex values of X, tan(X) returns complex values.
Plot Tangent Function

Try This ExampleCopy Code Copy Command


Plot the tangent function over the domain −π/2≤x≤π/2.
x = (-pi/2)+0.01:0.01:(pi/2)-0.01;
plot(x,tan(x)), grid on
Tangent of Vector of Complex Angles

Example: Calculate the tangent of the complex angles in vector x.


x = [-i pi+i*pi/2 -1+i*4];
y = tan(x)
y = 1×3 complex
0.0000 - 0.7616i -0.0000 + 0.9172i -0.0006 + 1.0003i
tand
Tangent of argument in degrees
Syntax

Y = tand(X)
Description

Y = tand(X) returns the tangent of the elements of X, which are expressed in degrees.
Examples

Tangent of 90 Degrees Compared to Tangent of π/2 Radians

Example:
tand(90)
ans = Inf
tan(pi/2)
ans = 1.6331e+16
tand(90) is infinite, whereas tan(pi/2) is large but finite.
Tangent of Vector of Complex Angles, Specified in Degrees

Example
z = [180+i 15+2i 10+3i];
y = tand(z)
y = 1×3 complex
0.0000 + 0.0175i 0.2676 + 0.0374i 0.1758 + 0.0539i
atan
Inverse tangent in radians
Syntax

Y = atan(X)
Description

Y = atan(X) returns the Inverse Tangent (tan-1) of the elements of X in radians. The function
accepts both real and complex inputs.
 For real values of X, atan(X) returns values in the interval [-π/2, π/2].
 For complex values of X, atan(X) returns complex values.
Inverse Tangent of a Value

Example: Find the inverse tangent of a value.


atan(0.8)
ans = 0.6747
Inverse Tangent of a Vector of Complex Values

Example: Find the inverse tangent of the elements of vector x. The atan function acts
on x element-wise.
x = [0.5i 1+3i -2.2+i];
Y = atan(x)
Y = 1×3 complex
0.0000 + 0.5493i 1.4615 + 0.3059i -1.2019 + 0.1506i
Plot the Inverse Tangent Function

Plot the inverse tangent function over the interval −20≤x≤20.


x = -20:0.01:20;
plot(x,atan(x))
grid on

atand
Inverse tangent in degrees
Syntax

Y = atand(X)
Description

Y = atand(X) returns the inverse tangent (tan-1) of the elements of X in degrees. The function
accepts both real and complex inputs.
 For real values of X, atand(X) returns values in the interval [-90, 90].
 For complex values of X, atand(X) returns complex values.
Inverse Tangent of Vector

Example
x = [-50 -20 0 20 50];
y = atand(x)
y = 1×5
-88.8542 -87.1376 0 87.1376 88.8542
The atand operation is element-wise when you pass a vector, matrix, or N-D array.
Inverse Tangent of Complex Value

Example:
atand(10+i)
ans = 84.3450 + 0.5618i
atan2
Four-quadrant inverse tangent
Syntax

P = atan2(Y,X)
Description

P = atan2(Y,X) returns the four-quadrant inverse tangent (tan-1) of Y and X, which must be real.
The atan2 function follows the convention that atan2(x,x) returns 0 when x is mathematically
zero (either 0 or -0).
Examples

Example: Find the four-quadrant inverse tangent of the point y = 4, x = -3.


atan2(4,-3)
ans = 2.2143
atan2d
Four-quadrant inverse tangent in degrees
Syntax

D = atan2d(Y,X)
Description

D = atan2d(Y,X) returns the four-quadrant inverse tangent (tan-1) of Y and X, which must be
real. The result, D, is expressed in degrees.
Inverse Tangent of Four Points on the Unit Circle

Example:
x = [1 0 -1 0];
y = [0 1 0 -1];
d = atan2d(y,x)
d = 1×4
0 90 180 -90
Four-Quadrant Inverse Tangent

The four-quadrant inverse tangent, atan2d(Y,X), returns values in the closed interval [-
180,180] based on the values of Y and X as shown in the graphic.

In contrast, atand(Y/X) returns results that are limited to the interval [-90,90], shown on the right
side of the diagram.
4. Csc
Cosecant of input angle in radians
Syntax

Y = csc(X)
Description

Y = csc(X) returns the cosecant of the elements of X. The csc function operates element-wise on
arrays. The function accepts both real and complex inputs.
 For real values of X, csc(X) returns real values in the interval [-∞, -1] and [1, ∞].
 For complex values of X, csc(X) returns complex values.
Plot Cosecant Function

Plot the cosecant function over the domain −π<x<0 and 0<x<π as shown.
x1 = -pi+0.01:0.01:-0.01;
x2 = 0.01:0.01:pi-0.01;
plot(x1,csc(x1),x2,csc(x2)), grid on
Cosecant of Vector of Complex Angles

Example: Calculate the cosecant of the complex angles in vector x.


x = [-i pi+i*pi/2 -1+i*4];
y = csc(x)
y = 1×3 complex
0.0000 + 0.8509i 0.0000 + 0.4345i -0.0308 - 0.0198i
cscd
Cosecant of argument in degrees
Syntax

Y = cscd(X)
Description

Y = cscd(X) returns the cosecant of the elements of X, which are expressed in degrees.
Cosecant of 180 Degrees Compared to Cosecant of π Radians

Example: cscd(180) is infinite, whereas csc(pi) is large but finite.


cscd(180)
ans = Inf
csc(pi)
ans = 8.1656e+15
Cosecant of Vector of Complex Angles, Specified in Degrees

Example
z = [35+i 15+2i 10+3i];
y = cscd(z)
y = 1×3 complex
1.7421 - 0.0434i 3.7970 - 0.4944i 5.2857 - 1.5681i
cospi
Compute cos(X*pi) accurately
Syntax

Y = cospi(X)
Description

Y = cospi(X) computes cos(X*pi) without explicitly computing X*pi. This calculation is more
accurate than cos(X*pi) because the floating-point value of pi is an approximation of π. In
particular:
 For odd integers, cospi(n/2) is exactly zero.
 For integers, cospi(n) is +1 or -1.
Calculate Cosine of Multiples of π

Example: Compare the accuracy of cospi(X) vs. cos(X*pi).


Create a vector of values.
X = [0 1/2 1 3/2 2];
Calculate the cosine of X*pi using the normal cos function.
Y = cos(X*pi)
Y = 1×5
1.0000 0.0000 -1.0000 -0.0000 1.0000
The results contain small numerical errors due to the fact that pi is a floating-point
approximation of the true value of π. For instance, Y(2) is not exactly zero even

though cos( =0.


π2)

Y(2)
ans = 6.1232e-17
Use cospi to calculate the same values. In this case, the results are exact.
Z = cospi(X)
Z = 1×5
1 0 -1 0 1
Z(2)
ans = 0
acsc
Inverse cosecant in radians
Syntax

Y = acsc(X)
Description

Y = acsc(X) returns the Inverse Cosecant (csc-1) of the elements of X in radians. The function
accepts both real and complex inputs.
 For real values of X in the intervals [-∞, -1] and [1, ∞], acsc(X) returns real values in the
interval [-π/2, π/2].
 For real values of X in the interval (-1, 1) and for complex values of X, acsc(X) returns
complex values.
Inverse Cosecant of a Value

Example: Find the inverse cosecant of a value.


acsc(3)
ans = 0.3398
Inverse Cosecant of a Vector of Complex Angles

Example: Find the inverse cosecant of the elements of vector x. The acsc function acts
on x element-wise.
x = [0.5i 1+3i -2.2+i];
Y = acsc(x)
Y = 1×3 complex
0.0000 - 1.4436i 0.0959 - 0.2970i -0.3795 - 0.1833i
Plot the Inverse Cosecant Function

Plot the inverse cosecant function over the intervals −10≤x<−1 and 1<x≤10.
x1 = -10:0.01:-1.01;
x2 = 1.01:0.01:10;
plot(x1,acsc(x1),'b')
hold on
plot(x2,acsc(x2),'b')
grid on
acscd
Inverse cosecant in degrees
Syntax

Y = acscd(X)
Description

Y = acscd(X) returns the inverse cosecant (cosec-1) of the elements of X in degrees. The function
accepts both real and complex inputs.
 For real values of X in the intervals [-∞, -1] and [1, ∞], acscd(X) returns values in the
range [-90, 90].
 For real values of X in the interval (-1, 1) and for complex values of X, acscd(X) returns
complex values.
Inverse Cosecant of Vector

Example:
x = [20 10 Inf];
y = acscd(x)
y = 1×3
2.8660 5.7392 0
The acscd operation is element-wise when you pass a vector, matrix, or N-D array.
Inverse Cosecant of Complex Value

Example:
acscd(1+i)
ans = 25.9136 -30.4033i
5. sec
Secant of angle in radians
Syntax

Y = sec(X)
Description

Y = sec(X) returns the secant of the elements of X. The sec function operates element-wise on
arrays. The function accepts both real and complex inputs.
 For real values of X, sec(X) returns real values in the interval [-∞, -1] and [1, ∞].
 For complex values of X, sec(X) returns complex values.
Plot Secant Function

Plot the secant over the domain −π/2<x<π/2 and π/2<x<3π/2.


x1 = -pi/2+0.01:0.01:pi/2-0.01;
x2 = pi/2+0.01:0.01:(3*pi/2)-0.01;
plot(x1,sec(x1),x2,sec(x2)), grid on
Secant of Vector of Complex Angles

Calculate the secant of the complex angles in vector x.


Example:
x = [-i pi+i*pi/2 -1+i*4];
y = sec(x)
y = 1×3 complex
0.6481 + 0.0000i -0.3985 + 0.0000i 0.0198 - 0.0308i
secd
Secant of argument in degrees
Syntax

Y = secd(X)
Description

Y = secd(X) returns the secant of the elements of X, which are expressed in degrees.
Examples: Secant of 90 Degrees Compared to Secant of π/2 Radians

secd(90)
ans = Inf
sec(pi/2)
ans = 1.6331e+16
secd(90) is infinite, whereas sec(pi/2) is large but finite.
Secant of Vector of Complex Angles, Specified in Degrees

Example:
z = [35+i 15+2i 10+3i];
y = secd(z)
y = 1×3 complex
1.2204 + 0.0149i 1.0346 + 0.0097i 1.0140 + 0.0094i
asec
Inverse secant in radians
Syntax

Y = asec(X)
Description

Y = asec(X) returns the Inverse Secant (sec-1) of the elements of X in radians. The function
accepts both real and complex inputs.
 For real values of X in the interval [-∞, -1] and [1, ∞], asec(X) returns values in the
interval [0, π].
 For real values of X in the interval (-1, 1) and for complex values of X, asec(X) returns
complex values.
Inverse Secant of a Value

Example: Find the inverse secant of a value.


asec(-2.8)
ans = 1.9360
Inverse Secant of a Vector of Complex Values

Example: Find the inverse secant of the elements of vector x. The asec function acts
on x element-wise.
x = [0.5i 1+3i -2.2+i];
Y = asec(x)
Y = 1×3 complex
1.5708 + 1.4436i 1.4749 + 0.2970i 1.9503 + 0.1833i
Plot the Inverse Secant Function

Example: Plot the inverse secant function over the intervals −5≤x≤−1 and 1≤x≤5.
x1 = -5:0.01:-1;
x2 = 1:0.01:5;
plot(x1,asec(x1),'b')
hold on
plot(x2,asec(x2),'b')
grid on
asecd
Inverse secant in degrees
Syntax

Y = asecd(X)
Description

Y = asecd(X) returns the inverse secant (sec-1) of the elements of X in degrees. The function
accepts both real and complex inputs.
 For real values of X in the intervals [-∞, -1] and [1, ∞], asecd(X) returns values in the
interval [0, 180].
 For real values of X in the interval (-1, 1) and for complex values of X, asecd(X) returns
complex values.
Inverse Secant of Vector

Example:
x = [10 1 Inf];
y = asecd(x)
y = 1×3
84.2608 0 90.0000
The asecd operation is element-wise when you pass a vector, matrix, or N-D array.
Inverse Secant of Complex Value

Example
asecd(1+i)
ans = 64.0864 +30.4033i
6. cot
Cotangent of angle in radians
Syntax

Y = cot(X)
Description

Y = cot(X) returns the cotangent of elements of X. The cot function operates element-wise on
arrays. The function accepts both real and complex inputs.
 For real values of X, cot(X) returns real values in the interval [-∞, ∞].
 For complex values of X, cot(X) returns complex values.
Plot Cotangent Function

Example: Plot the cotangent function over the domain −π<x<0 and 0<x<π.
x1 = -pi+0.01:0.01:-0.01;
x2 = 0.01:0.01:pi-0.01;
plot(x1,cot(x1),x2,cot(x2)), grid on
Cotangent of Vector of Complex Angles

Example: Calculate the cotangent of the complex angles in vector x.


x = [-i pi+i*pi/2 -1+i*4];
y = cot(x)
y = 1×3 complex
0.0000 + 1.3130i -0.0000 - 1.0903i -0.0006 - 0.9997i
cotd
Cotangent of argument in degrees
Syntax

Y = cotd(X)
Description

Y = cotd(X) returns the cotangent of the elements of X, which are expressed in degrees.
Example:
cotd(90)
ans =
0
cotd(pi/2)
ans =
36.466487130706170
Cotangent of Complex Angle, Specified in Degrees

Example
x = 35+5i;
y = cotd(x)
y = 1.3958 - 0.2606i
acot
Inverse cotangent in radians
Syntax

Y = acot(X)
Description

Y = acot(X) returns the Inverse Cotangent (cot-1) of the elements of X in radians. The function
accepts both real and complex inputs.
 For real values of X, acot(X) returns values in the interval [-π/2, π/2].
 For complex values of X, acot(X) returns complex values.
Inverse Cotangent of a Value

Example: Find the inverse cotangent of a value.


acot(2.6)
ans = 0.3672
Inverse Cotangent of a Vector of Complex Values

Example: Find the inverse cotangent of the elements of vector x. The acot function acts
on x element-wise.
x = [0.5i 1+3i -2.2+i];
Y = acot(x)
Y = 1×3 complex
1.5708 - 0.5493i 0.1093 - 0.3059i -0.3689 - 0.1506i
Plot the Inverse Cotangent Function

Example: Plot the inverse cotangent function over the intervals −2π≤x<0 and 0<x≤2π.
x1 = -2*pi:pi/30:-0.1;
x2 = 0.1:pi/30:2*pi;
plot(x1,acot(x1),'b')
hold on
plot(x2,acot(x2),'b')
grid on

acotd
Inverse cotangent in degrees
Syntax

Y = acotd(X)
Description

Y = acotd(X) returns the inverse cotangent (cot-1) of the elements of X in degrees. The function
accepts both real and complex inputs.
 For real values of X, acotd(X) returns values in the range [-90, 90].
 For complex values of X, acotd(X) returns complex values.
Inverse Cotangent of Vector

Example
x = [0 20 Inf];
y = acotd(x)
y = 1×3
90.0000 2.8624 0
The acotd operation is element-wise when you pass a vector, matrix, or N-D array.
Inverse Cotangent of Complex Value

Example:
acotd(1+i)
ans = 31.7175 -23.0535i
hypot
Square root of sum of squares (hypotenuse)
Syntax

C = hypot(A,B)
Description

C = hypot(A,B) returns the result of the following equation:


C = sqrt(abs(A).^2 + abs(B).^2)
Compute Hypotenuse

Example: Compute the hypotenuse of a right triangle with side lengths of 3 and 4.
C = hypot(3,4)
C=5
deg2rad
Convert angle from degrees to radians
Syntax

R = deg2rad(D)
Description

R = deg2rad(D) converts angle units from degrees to radians for each element of D.
Right Angle in Radians

Example: Convert a 90-degree angle into radians.


R = deg2rad(90)
R = 1.5708
rad2deg
rad2deg
Convert angle from radians to degrees
Syntax

D = rad2deg(R)
Description

D = rad2deg(R) converts angle units from radians to degrees for each element of R.
Example: Convert pi into degrees.
D = rad2deg(pi)
D = 180

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy