MATLAB: Functios in MatLab for matrixes

logical?matrix manipulation

Is there a function that, once introduced any matrix, counts how many 0's there are, how many elements between 0 and 1, and how many are bigger than 1 in said matrix? Thanks!

Best Answer

x = rand(100);
n0 = sum(x(:) == 0);
n0to1 = sum(x(:) > 0 & x(:) <= 1);
ngt1 = sum(x(:) > 1);