This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

angdiff

Difference between two angles

Syntax

delta = angdiff(alpha,beta)
delta = angdiff(alpha)

Description

example

delta = angdiff(alpha,beta) calculates the difference between the angles alpha and beta. This function subtracts alpha from beta with the result wrapped on the interval [-pi,pi]. You can specify the input angles as single values or as arrays of angles that have the same number of values.

example

delta = angdiff(alpha) returns the angular difference between adjacent elements of alpha along the first dimension whose size does not equal 1. If alpha is a vector of length n, the first entry is subtracted from the second, the second from the third, etc. The output, delta, is a vector of length n-1. If alpha is an m-by-n matrix with m greater than 1, the output, delta, will be a matrix of size m-1-by-n.

Examples

collapse all

d = angdiff(pi,2*pi)
d = 3.1416
d = angdiff([pi/2 3*pi/4 0],[pi pi/2 -pi])
d = 1×3

    1.5708   -0.7854   -3.1416

angles = [pi pi/2 pi/4 pi/2];
d = angdiff(angles)
d = 1×3

   -1.5708   -0.7854    0.7854

Input Arguments

collapse all

Angle in radians, specified as a scalar, vector, matrix, or multidimensional array. This is the angle that is subtracted from beta when specified.

Example: pi/2

Angle in radians, specified as a scalar, vector, matrix, or multidimensional array of the same size as alpha. This is the angle that alpha is subtracted from when specified.

Example: pi/2

Output Arguments

collapse all

Angular difference between two angles, returned as a scalar, vector, or array. delta is wrapped to the interval [-pi,pi].

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2015a