minus, -

Quaternion subtraction

Description

example

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.

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, array of quaternions, real number, or array of real numbers.

Data Types: quaternion | single | double

Input, specified as a quaternion, array of quaternions, real number, or array of real numbers.

Data Types: quaternion | single | double

Output Arguments

collapse all

Result of quaternion subtraction, returned as a scalar, vector, matrix, or multidimensional array of quaternions.

Data Types: quaternion