Scalar component of a quaternion
r = s(q), r = scalar(q)
These two functions extract the scalar component of a quaternion or octonion. The result is a real (or a complex value if the quaternion/octonion has complex components).
The two functions differ in their behaviour when given a pure array (that is a quaternion/octonion with no scalar part). The function s returns an empty array in this case, whereas scalar returns a zero array of the same size as the pure array, with the same class as the components of the array. For example if the pure quaternion/octonion has components of class uint8 the array of zeros returned will also be of class uint8.
>> q = eyeq(2) q = 2x2 quaternion array >> s(q) ans = 1 0 0 1 >> scalar(qi) ans = 0