compact
Convert quaternion array to N-by-4 matrix
Syntax
Description
Examples
Convert Quaternion Array to Compact Representation of Parts
Create a scalar quaternion with random parts. Convert the parts to a 1-by-4 vector using compact
.
randomParts = randn(1,4)
randomParts = 1×4
0.5377 1.8339 -2.2588 0.8622
quat = quaternion(randomParts)
quat = quaternion
0.53767 + 1.8339i - 2.2588j + 0.86217k
quatParts = compact(quat)
quatParts = 1×4
0.5377 1.8339 -2.2588 0.8622
Create a 2-by-2 array of quaternions, then convert the representation to a matrix of quaternion parts. The output rows correspond to the linear indices of the quaternion array.
quatArray = [quaternion([1:4;5:8]),quaternion([9:12;13:16])]
quatArray = 2x2 quaternion array
1 + 2i + 3j + 4k 9 + 10i + 11j + 12k
5 + 6i + 7j + 8k 13 + 14i + 15j + 16k
quatArrayParts = compact(quatArray)
quatArrayParts = 4×4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Input Arguments
quat
— Quaternion to convert
quaternion
object | array of quaternion
objects
Quaternion to convert, specified as a quaternion
object or an array of quaternion
objects of any dimensionality.
Output Arguments
matrix
— Quaternion in matrix form
N-by-4 numeric matrix
Quaternion in matrix form, returned as an N-by-4
numeric matrix, where N is the number of quaternions
given in the input quat
.
Data Types: single
| double
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
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)