Diagonal matrices and diagonals of a matrix.
(Quaternion and octonion overloadings of standard MATLAB® function)
Y = diag(X, K)
diag(X) returns the diagonal elements of the quaternion matrix X. If X is a vector, diag(X) constructs a quaternion diagonal matrix using the elements of the vector as the diagonal elements. The second parameter must be a scalar integer indicating the main diagonal (K = 0), super diagonals (K > 1), or sub diagonals (K < 1).
>> diag([qi, qj, qk]) ans = 3x3 pure quaternion array >> show(ans) ans.X = 1 0 0 0 0 0 0 0 0 ans.Y = 0 0 0 0 1 0 0 0 0 ans.Z = 0 0 0 0 0 0 0 0 1