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

    %% Zero and Nonzero Elements in Matrix
% Find the nonzero elements in a 3-by-3 matrix.

% Copyright 2015 The MathWorks, Inc.

X = [1 0 2; 0 1 1; 0 0 4]

%%
%
k = find(X)

%%
% Use the logical |not| operator on |X| to locate the zeros.
k2 = find(~X)