www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/TestDiagonalMatrixExample.m

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