MATLAB: Writing code to calculate number of ones & zeros in the logic matrix

image & signal processingImage Processing Toolbox

Hi all, I'd like to write code to find number of ones & number of zeros ones respectively in logic matrix (1×34) attached below: I will be so grateful if someone help me. Best Regards

Best Answer

RLE = diff([0 find(diff(A)~=0) length(A)]);