function flag=identitymat_alternative(A) sz=size(A); n=sz(1); count=0; for i=1:1:n for j=1:1:n if (A(i,j)==1) & (i==j) count=count+1; end if (A(i,j)==0) & (i~=j) count=count+1; end end end if count==n^2 flag=22; else flag=66; end