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);clcidx= 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
MATLAB: Can develop this answer to print (‘no hole’) if the condition of the number of zeros is not satisfy ,please
consecutive numbersMATLAB
Best Answer