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.


Calculate product of two quaternions


n = quatmultiply(q,r)


n = quatmultiply(q,r) calculates the quaternion product, n, for two given quaternions, q and r. Inputs q and r can each be either an m-by-4 matrix containing m quaternions, or a single 1-by-4 quaternion. n returns an m-by-4 matrix of quaternion products. Each element of q and r must be a real number. Additionally, q and r have their scalar number as the first column.

The quaternions have the form of




The quaternion product has the form of





Quaternion multiplication is not commutative.


Determine the product of two 1-by-4 quaternions:

q = [1 0 1 0];
r = [1 0.5 0.5 0.75];
mult = quatmultiply(q, r)

mult =

    0.5000    1.2500    1.5000    0.2500

Determine the product of a 1-by-4 quaternion with itself:

q = [1 0 1 0];
mult = quatmultiply(q)

mult =

     0     0     2     0

Determine the product of 1-by-4 and 2-by-4 quaternions:

q = [1 0 1 0];
r = [1 0.5 0.5 0.75; 2 1 0.1 0.1];
mult = quatmultiply(q, r)

mult =

    0.5000    1.2500    1.5000    0.2500
    1.9000    1.1000    2.1000   -0.9000


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

Extended Capabilities

Introduced in R2006b