"SM" wrote in message <j9uts6$o9i$1@newscl01ah.mathworks.com>...
> [ 0 1 0 0 3 4 0 0 0 0 0 2 3 4 5 0 0 0
> 1 Go through the row 1 and group the nonzero data in row ignore if there is less than 2 zeros in between.
>
> Basically during the first iteration the result will be:
> Gr11= [1 0 0 3 4]
> Gr12= [2 3 4 5]
         
This isn't a complete answer but perhaps I can assist with the "grouping" action of step 1 and leave the other steps to you (or others.)
Let x be a row in your matrix. Then do this:
x1 = [x,0,0,0]; x23 = [0,x,0,0][0,0,x,0]; x4 = [0,0,0,x];
f1 = find(x1 & ~(x23x4));
f2 = find(x4 & ~(x1x23))3;
Then f1 will contain the indices of the start of each "group" in this row and the corresponding f2 values will be the ending indices of these same groups  (f1 and f2 of necessity must possess the same number of indices.) That should suffice to uniquely determine your groups.
Note that it is quite possible to have different numbers of groups in your various rows, so you will probably have to store them in a cell array.
Note 2: You stated "ignore if there is less than 2 zeros" but in your example you seemed to "ignore" if there were two or fewer zeros.
Roger Stafford
