%% Test Diagonal Matrix
% Create a 4-by-4 identity matrix.

I = eye(4)

%
% Test to see if the matrix is diagonal.

isdiag(I)

% The result is logical 1 (true) because all of the nonzero elements in I are on the main diagonal.
% Copyright 2012 The MathWorks, Inc.