Main Content

minus, -

Quaternion subtraction

Syntax

Description

C = A - B subtracts quaternion B from quaternion A using quaternion subtraction. Either A or B may be a real number, in which case subtraction is performed with the real part of the quaternion argument.

example

Examples

collapse all

Quaternion subtraction is defined as the subtraction of the corresponding parts of each quaternion. Create two quaternions and perform subtraction.

Q1 = quaternion([1,0,-2,7]);
Q2 = quaternion([1,2,3,4]);

Q1minusQ2 = Q1 - Q2
Q1minusQ2 = quaternion
     0 - 2i - 5j + 3k

Addition and subtraction of real numbers is defined for quaternions as acting on the real part of the quaternion. Create a quaternion and then subtract 1 from the real part.

Q = quaternion([1,1,1,1])
Q = quaternion
     1 + 1i + 1j + 1k

Qminus1 = Q - 1
Qminus1 = quaternion
     0 + 1i + 1j + 1k

Input Arguments

collapse all

Input, specified as a quaternion object, an array of quaternion objects of any dimensionality, a real scalar, or an array of real numbers of any dimensionality. Numeric values must be of data type single or double.

A and B must have compatible sizes. In the simplest cases, they can be the same size or one can be a scalar. Two inputs have compatible sizes if, for every dimension, the dimension sizes of the inputs are the same or one of the dimensions is 1.

Input, specified as a quaternion object, an array of quaternion objects of any dimensionality, a real scalar, or an array of real numbers of any dimensionality. Numeric values must be of data type single or double.

A and B must have compatible sizes. In the simplest cases, they can be the same size or one can be a scalar. Two inputs have compatible sizes if, for every dimension, the dimension sizes of the inputs are the same or one of the dimensions is 1.

Output Arguments

collapse all

Result of quaternion subtraction, returned as a quaternion object or an array of quaternion objects.

Extended Capabilities

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

See Also

Functions

Objects