MATLAB: Can develop this answer to print (‘no hole’) if the condition of the number of zeros is not satisfy ,please

consecutive numbersMATLAB

x=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 2 2 0 0 0 1 1 0 0 0 0 4 4];
%use this:
%[b,n]=RunLength(x);
%or this :
ii = [ find(x(1:end-1) ~= x(2:end)) length(x) ];
n = diff([ 0 ii ]);
b = x(ii);
clc
idx= b==0 & n>=10;
for k=find(idx)
start=1+sum(n(1:(k-1)));stop=start+n(k)-1;
fprintf('hole from %d to %d\n',start,stop)
end

Best Answer

It is a bit redundant, but here is the code I was refering to:
x=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 2 2 0 0 0 1 1 0 0 0 0 4 4];
%use this (function from the FEX):
%[b,n]=RunLength(x);
%or this:
ii = [ find(x(1:end-1) ~= x(2:end)) length(x) ];
n = diff([ 0 ii ]);
b = x(ii);
clc
idx= b==0 & n>=10;
if any(idx)
for k=find(idx)
start=1+sum(n(1:(k-1)));stop=start+n(k)-1;
fprintf('hole from %d to %d\n',start,stop)
end
else
disp('no holes')
end