Component of a quaternion or octonion
p = part(q, n)
This function extracts one of the four components of a quaternion or one of the eight components of an octonion. The result is a real (or a complex value if the quaternion/octonion has complex components). The parameter must be an integer in the range 1:4 or 1:8 as appropriate. For quaternions, there are also three named functions x, y, and z that can also access the components of the vector part. These are not provided for octonions, as the present function seemed a better implementation, since it is possible to index through the components. The scalar part can also be accessed through the s and scalar functions, which differ in their behaviour if the quaternion/octonion is pure. The present function behaves like s and returns an empty array for a pure quaternion or octonion.
>> q = quaternion(1, 2, 3, 4) q = 1 + 2 * I + 3 * J + 4 * K >> part(q, 3) ans = 3