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

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)

% Copyright 2015 The MathWorks, Inc.