%% Number of Elements Meeting a Condition
% Use nnz in conjunction with a relational operator to determine how many matrix elements meet a condition. Since relational operators produce logical matrices of 1s and 0s, the nnz function counts the 1s where the condition is true.
%
% Create a matrix and determine how many elements are greater than 10.

X = magic(5)

%

nnz(X>10)

% Copyright 2018 The MathWorks, Inc.