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.

prod

Product of a quaternion array

Syntax

quatProd = prod(quat)
quatProd = prod(quat,dim)

Description

example

quatProd = prod(quat) returns the quaternion product of the elements of the array.

example

quatProd = prod(quat,dim) calculates the quaternion product along dimension dim.

Examples

collapse all

Create a 3-by-3 array whose elements correspond to their linear indices.

A = reshape(quaternion(randn(9,4)),3,3)
A = 3x3 quaternion array
      0.53767 +   2.7694i +    1.409j -  0.30344k      0.86217 +   0.7254i -   1.2075j +   0.8884k     -0.43359 -  0.20497i +  0.48889j -   0.8095k
       1.8339 -   1.3499i +   1.4172j +  0.29387k      0.31877 - 0.063055i +  0.71724j -   1.1471k      0.34262 -  0.12414i +   1.0347j -   2.9443k
      -2.2588 +   3.0349i +   0.6715j -  0.78728k      -1.3077 +  0.71474i +   1.6302j -   1.0689k       3.5784 +   1.4897i +  0.72689j +   1.4384k

Find the product of the quaternions in each column. The length of the first dimension is 1, and the length of the second dimension matches size(A,2).

B = prod(A)
B = 1x3 quaternion array
     -19.837 -  9.1521i +  15.813j -  19.918k     -5.4708 - 0.28535i +   3.077j -  1.2295k      -10.69 -  8.5199i -  2.8801j - 0.65338k

You can specify which dimension of a quaternion array to take the product of.

Create a 2-by-2-by-2 quaternion array.

A = reshape(quaternion(randn(8,4)),2,2,2);

Find the product of the elements in each page of the array. The length of the first dimension matches size(A,1), the length of the second dimension matches size(A,2), and the length of the third dimension is 1.

dim = 3;
B = prod(A,dim)
B = 2x2 quaternion array
     -2.4847 +  1.1659i - 0.37547j +  2.8068k     0.28786 - 0.29876i - 0.51231j -  4.2972k
     0.38986 -  3.6606i -  2.0474j -   6.047k      -1.741 - 0.26782i +  5.4346j +  4.1452k

Input Arguments

collapse all

Quaternion, specified as scalar, vector, matrix, or multidimensional array of quaternions.

Example: qProd = prod(quat) calculates the quaternion product along the first non-singleton dimension of quat.

Data Types: quaternion

Dimension along which to calculate the quaternion product, specified as a positive integer. If dim is not specified, prod operates along the first non-singleton dimension of quat.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Quaternion product, returned as quaternion array with one less non-singleton dimension than quat.

For example, if quat is a 2-by-2-by-5 array,

  • prod(quat,1) returns a 1-by-2-by-5 array.

  • prod(quat,2) returns a 2-by-1-by-5 array.

  • prod(quat,3) returns a 2-by-2 array.

Data Types: quaternion

Extended Capabilities

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

Introduced in R2018a