prod
Description
Examples
Product of Quaternions in Each Column
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
Product of Specified Dimension of Quaternion Array
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
quat
— Quaternions
array of quaternion
objects
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
.
dim
— Dimension
positive integer
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
quatProd
— Quaternion product
array of quaternion
objects
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 R2021a
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)