# meanrot

## Description

returns the average rotation of the elements of `quatAverage`

= meanrot(`quat`

)`quat`

along the
first array dimension whose size not does equal 1.

If

`quat`

is a vector,`meanrot(quat)`

returns the average rotation of the elements.If

`quat`

is a matrix,`meanrot(quat)`

returns a row vector containing the average rotation of each column.If

`quat`

is a multidimensional array, then`mearot(quat)`

operates along the first array dimension whose size does not equal 1, treating the elements as vectors. This dimension becomes 1 while the sizes of all other dimensions remain the same.

The `meanrot`

function normalizes the input quaternions,
`quat`

, before calculating the mean.

return the average rotation along dimension `quatAverage`

= meanrot(`quat`

,`dim`

)`dim`

. For example,
if `quat`

is a matrix, then `meanrot(quat,2)`

is
a column vector containing the mean of each row.

specifies whether to include or omit `quatAverage`

= meanrot(___,`nanflag`

)`NaN`

values from the
calculation for any of the previous syntaxes.
`meanrot(quat,"includenan")`

includes all
`NaN`

values in the calculation while
`mean(quat,"omitnan")`

ignores them.

## Examples

## Input Arguments

## Output Arguments

## Algorithms

`meanrot`

determines a quaternion mean, $$\overline{q}$$, according to [1]. $$\overline{q}$$ is the quaternion that minimizes the squared Frobenius norm of the
difference between rotation matrices:

$$\overline{q}=\mathrm{arg}\begin{array}{c}\mathrm{min}\\ q\in {\text{S}}^{3}\end{array}{\displaystyle \sum _{i=1}^{n}{\Vert A\left(q\right)-A\left({q}_{i}\right)\Vert}_{F}^{2}}$$

## References

[1] Markley, F. Landis, Yang Chen, John
Lucas Crassidis, and Yaakov Oshman. "Average Quaternions." *Journal of
Guidance, Control, and Dynamics*. Vol. 30, Issue 4, 2007, pp.
1193-1197.

## Extended Capabilities

## Version History

**Introduced in R2020a**