prod
Description
Examples
Create a 3-by-3 array whose elements correspond to their linear indices.
A = reshape(quaternion(randn(9,4)),3,3)
A = 3×3 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 = 1×3 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 = 2×2 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
Quaternions, specified as an array of quaternion
objects of any dimensionality.
Example: qProd = prod(quat)
calculates the quaternion
product along the first non-singleton dimension of
quat
.
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
Quaternion product, returned as an array of quaternion
objects. quatProd
has one less non-singleton dimension
than quat
.
For example, if quat
is a 2-by-2-by-5 array,
prod(
returns a 1-by-2-by-5 array.quat
,1)prod(
returns a 2-by-1-by-5 array.quat
,2)prod(
returns a 2-by-2 array.quat
,3)
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2023b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)