Quaternion Function Reference

diag

Diagonal matrices and diagonals of a matrix.
(Quaternion and octonion overloadings of standard MATLAB® function)

Syntax

Y = diag(X, K)

Description

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).

Examples

>> 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

See Also

MATLAB® function: diag
QTFM functions: blkdiag, tril, triu

© 2008-2013 Stephen J. Sangwine and Nicolas Le Bihan

License terms.