If you have the "c" as an integer or logical array, and if you have the Image Processing Toolbox, you can do it in one line with regionprops(). Just simply say "measurements = regionprops(~c, 'Area')" Here's a full demo:
c = [0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0]
measurements = regionprops(~c, 'Area')
fprintf('The number of zero sections is %d.\n', length(measurements));
fprintf('The sizes of zero sections are:\n');
allAreas = [measurements.Area]
Best Answer