# quatinv

Calculate inverse of quaternion

## Syntax

``n = quatinv(q)``

## Description

````n = quatinv(q)` calculates the inverse, `n`, for a given quaternion, `q`. Aerospace Toolbox uses quaternions that are defined using the scalar-first convention. For more information on quaternion forms, see Algorithms.```

## Examples

collapse all

Calculate the inverse of a quaternion q.

`qinv = quatinv([1 0 1 0])`
```qinv = 1×4 0.5000 0 -0.5000 0 ```

## Input Arguments

collapse all

Quaternion, specified as an m-by-4 matrix containing m quaternions.

Data Types: `double`

## Output Arguments

collapse all

Inverse of quaternion, returned as an m-by-4 matrix.

## Algorithms

The quaternion has the form of

`$q={q}_{0}+i{q}_{1}+j{q}_{2}+k{q}_{3}.$`

The quaternion inverse has the form of

`${q}^{-1}=\frac{{q}_{0}-i{q}_{1}-j{q}_{2}-k{q}_{3}}{{q}_{0}^{2}+{q}_{1}^{2}+{q}_{2}^{2}+{q}_{3}^{2}}.$`

## References

[1] Stevens, Brian L., Frank L. Lewis, Aircraft Control and Simulation, Wiley–Interscience, 2nd Edition.

## Version History

Introduced in R2006b