A matrix is diagonal if all elements above
and below the main diagonal are zero. Any number of the elements on
the main diagonal can also be zero.
For example, the 4-by-4 identity matrix,
is a diagonal matrix. Diagonal matrices are typically, but not
always, square.
Tips
Use the diag function
to produce diagonal matrices for which isdiag returns
logical 1 (true).
The functions isdiag, istriu,
and istril are special cases of the function isbanded, which can perform all of the
same tests with suitably defined upper and lower bandwidths. For example, isdiag(A)
== isbanded(A,0,0).