I have a matrix filled with zeros and ones and I need to count the number of ones in each row. Then I need to know which row's count exceeds or equal a specific limit (any number, for example 3). After that foreach row in these rows I need to create a vector that holds the index of all the columns which has non-zero values in that row and in all the rows above it and below it till it reach a row with zero count.

Example:
data contains the data below:

```
0 0 0 0 0 0 0
0 0 0 1 1 0 0
0 1 0 0 1 0 1
0 0 0 0 0 0 0
0 1 0 0 0 0 0 
0 1 1 1 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 0 0

```

The output should be if the limit is 3:

```
Row 3: col 4 5 2 5 7 
Row 6: col 2 2 3 4 3 

```

I already read the data and I counted the ones in the code below:

```
load('data');
mat(isnan(mat)) = 0;
[rows,cols,vals]  = find(mat~= 0);
unqRows=unique(rows);
countElinRows=histc(rows,unqRows);

```

---

**Edit for clarification as requested by commentators:**

If the third row of the given sample input array becomes `[0 1 0 0 0 0 1]`, then we must only have this output - 

```
Row 6: col 2 2 3 4 3

```