|
Prev: video input keeps stopping frequently and automatically
Next: Reshaping a vector into varying size lines
From: Jessica on 18 Jun 2008 15:52 dpb <none(a)non.net> wrote in message <g39vfm$fnj$1(a)aioe.org>... > Jessica wrote: > ... > > and I would like to be able to identify both clumps of > > zeros by having their start and stop row numbers. > > As a starting point, > > z = find(x==0); % find the locations of zeroes > dz = diff(z) ; % if dz==1, consecutive zeroes > > Work back from initial location of where dz==1 occurs to the > corresponding location in z. The first in a sequence will be one less > than the location in dz and the last the last. > > -- Great suggestion. I got it to work!
From: us on 18 Jun 2008 16:09
"Jessica ": <SNIP gap-finder evergreen... one of the many solutions % the data d=[0,1,2,0,0,3,4,0,6,0]; % the engine dd=[true,d~=0,true]; ixb=strfind(dd,[1,0]); ixe=strfind(dd,[0,1])-1; % the result r=[ixb;ixe;ixe-ixb+1] %{ 1 4 8 10 % start 1 5 8 10 % end 1 2 1 1 % #zeros %} us |