MATLAB: Count percentage of zero elements of a matrix

image processingimage segmentation

Hi,
I want to count the percentage of zero elements of a matrix. For an example, I have matrix 3×3
M = [1 1 0 1 0 0 0 0 0]
Can anyone help me with Matlab code?I'm a newbie with Matlab. Tq

Best Answer

Hint: look at nnz()